Package org.hibernate.search

Examples of org.hibernate.search.SearchException


          log.trace( "Field {} projected as {}", fieldName, result[matchingPosition] );
        }
      }
      else {
        if ( store == Field.Store.NO ) {
          throw new SearchException( "Projecting an unstored field: " + fieldName );
        }
        else {
          throw new SearchException( "FieldBridge is not a TwoWayFieldBridge: " + fieldBridge.getClass() );
        }
      }
    }
  }
View Full Code Here


      try {
        Class processorFactoryClass = ReflectHelper.classForName( backend, BatchedQueueingProcessor.class );
        backendQueueProcessorFactory = ( BackendQueueProcessorFactory ) processorFactoryClass.newInstance();
      }
      catch ( ClassNotFoundException e ) {
        throw new SearchException( "Unable to find processor class: " + backend, e );
      }
      catch ( IllegalAccessException e ) {
        throw new SearchException( "Unable to instanciate processor class: " + backend, e );
      }
      catch ( InstantiationException e ) {
        throw new SearchException( "Unable to instanciate processor class: " + backend, e );
      }
    }
    backendQueueProcessorFactory.initialize( properties, searchFactoryImplementor );
    searchFactoryImplementor.setBackendQueueProcessorFactory( backendQueueProcessorFactory );
  }
View Full Code Here

      loader.setEntityTypes( classes );
      return loader;
    }
    if ( criteria != null ) {
      if ( classes.length > 1 ) {
        throw new SearchException( "Cannot mix criteria and multiple entity types" );
      }
      if ( criteria instanceof CriteriaImpl ) {
        String targetEntity = ( ( CriteriaImpl ) criteria ).getEntityOrClassName();
        if ( classes.length == 1 && !classes[0].getName().equals( targetEntity ) ) {
          throw new SearchException( "Criteria query entity should match query entity" );
        }
        else {
          try {
            Class entityType = ReflectHelper.classForName( targetEntity );
            classes = new Class[] { entityType };
          }
          catch ( ClassNotFoundException e ) {
            throw new SearchException( "Unable to load entity class from criteria: " + targetEntity, e );
          }
        }
      }
      QueryLoader loader = new QueryLoader();
      loader.init( session, searchFactoryImplementor );
View Full Code Here

  public Explanation explain(int documentId) {
    Explanation explanation = null;
    SearchFactoryImplementor searchFactoryImplementor = getSearchFactoryImplementor();
    Searcher searcher = buildSearcher( searchFactoryImplementor );
    if ( searcher == null ) {
      throw new SearchException(
          "Unable to build explanation for document id:"
              + documentId + ". no index found"
      );
    }
    try {
View Full Code Here

    if ( def.getFactoryMethod() != null ) {
      try {
        filter = ( Filter ) def.getFactoryMethod().invoke( instance );
      }
      catch ( IllegalAccessException e ) {
        throw new SearchException(
            "Unable to access @Factory method: "
                + def.getImpl().getName() + "." + def.getFactoryMethod().getName()
        );
      }
      catch ( InvocationTargetException e ) {
        throw new SearchException(
            "Unable to access @Factory method: "
                + def.getImpl().getName() + "." + def.getFactoryMethod().getName()
        );
      }
      catch ( ClassCastException e ) {
        throw new SearchException(
            "@Key method does not return a org.apache.lucene.search.Filter class: "
                + def.getImpl().getName() + "." + def.getFactoryMethod().getName()
        );
      }
    }
    else {
      try {
        filter = ( Filter ) instance;
      }
      catch ( ClassCastException e ) {
        throw new SearchException(
            "Filter implementation does not implement the Filter interface: "
                + def.getImpl().getName() + ". "
                + ( def.getFactoryMethod() != null ? def.getFactoryMethod().getName() : "" ), e
        );
      }
View Full Code Here

    else {
      try {
        key = ( FilterKey ) def.getKeyMethod().invoke( instance );
      }
      catch ( IllegalAccessException e ) {
        throw new SearchException(
            "Unable to access @Key method: "
                + def.getImpl().getName() + "." + def.getKeyMethod().getName()
        );
      }
      catch ( InvocationTargetException e ) {
        throw new SearchException(
            "Unable to access @Key method: "
                + def.getImpl().getName() + "." + def.getKeyMethod().getName()
        );
      }
      catch ( ClassCastException e ) {
        throw new SearchException(
            "@Key method does not return FilterKey: "
                + def.getImpl().getName() + "." + def.getKeyMethod().getName()
        );
      }
    }
View Full Code Here

    Object instance;
    try {
      instance = def.getImpl().newInstance();
    }
    catch ( InstantiationException e ) {
      throw new SearchException( "Unable to create @FullTextFilterDef: " + def.getImpl(), e );
    }
    catch ( IllegalAccessException e ) {
      throw new SearchException( "Unable to create @FullTextFilterDef: " + def.getImpl(), e );
    }
    for ( Map.Entry<String, Object> entry : fullTextFilter.getParameters().entrySet() ) {
      def.invoke( entry.getKey(), instance, entry.getValue() );
    }
    if ( cacheInstance( def.getCacheMode() ) && def.getKeyMethod() == null && fullTextFilter.getParameters()
        .size() > 0 ) {
      throw new SearchException( "Filter with parameters and no @Key method: " + fullTextFilter.getName() );
    }
    return instance;
  }
View Full Code Here

    filterDefinition = new FullTextFilterImpl();
    filterDefinition.setName( name );
    FilterDef filterDef = getSearchFactoryImplementor().getFilterDefinition( name );
    if ( filterDef == null ) {
      throw new SearchException( "Unkown @FullTextFilter: " + name );
    }
    filterDefinitions.put( name, filterDefinition );
    return filterDefinition;
  }
View Full Code Here

      indexName = indexDir.getCanonicalPath();
      //this is cheap so it's not done in start()
      directory = DirectoryProviderHelper.createFSIndex( indexDir );
    }
    catch (IOException e) {
      throw new SearchException( "Unable to initialize index: " + directoryProviderName, e );
    }
  }
View Full Code Here

      idBridge =  new TwoWayString2FieldBridgeAdaptor( org.hibernate.search.bridge.builtin.StringBridge.INSTANCE );
      idKeywordName = ProvidedId.defaultFieldName;
      idProvided = true;
    }
    if ( idKeywordName == null ) {
      throw new SearchException( "No document id in: " + clazz );
    }
    CacheFromIndex fieldCacheOptions = clazz.getAnnotation( CacheFromIndex.class );
    if ( fieldCacheOptions == null ) {
      this.fieldCacheUsage = Collections.unmodifiableSet( EnumSet.of( org.hibernate.search.annotations.FieldCacheType.CLASS ) );
    }
    else {
      EnumSet<org.hibernate.search.annotations.FieldCacheType> enabledTypes = EnumSet.noneOf( org.hibernate.search.annotations.FieldCacheType.class );
      Collections.addAll( enabledTypes, fieldCacheOptions.value() );
      if ( enabledTypes.size() != 1 && enabledTypes.contains( org.hibernate.search.annotations.FieldCacheType.NOTHING ) ) {
        throw new SearchException( "CacheFromIndex configured with conflicting parameters:" +
            " if FieldCacheType.NOTHING is enabled, no other options can be added" );
      }
      this.fieldCacheUsage = Collections.unmodifiableSet( enabledTypes );
    }
    checkAllowFieldSelection();
View Full Code Here

TOP

Related Classes of org.hibernate.search.SearchException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.