Package org.hibernate.search

Examples of org.hibernate.search.SearchException


    if ( nbrOfShardsString != null ) {
      try {
        nbrOfShards = Integer.parseInt( nbrOfShardsString );
      }
      catch (NumberFormatException e) {
        throw new SearchException(indexName + "." + NBR_OF_SHARDS + " is not a number", e);
      }
    }
    if ( nbrOfShards <= 0 && indexSpecificProps.size() == 0 ) {
      //no shard (a shareded subindex has to have at least one property
      return new Properties[] { indexSpecificDefaultProps };
View Full Code Here


  }

  private static String defineIndexingStrategy(SearchConfiguration cfg) {
    String indexingStrategy = cfg.getProperties().getProperty( Environment.INDEXING_STRATEGY, "event" );
    if ( ! ("event".equals( indexingStrategy ) || "manual".equals( indexingStrategy ) ) ) {
      throw new SearchException( Environment.INDEXING_STRATEGY + " unknown: " + indexingStrategy );
    }
    return indexingStrategy;
  }
View Full Code Here

    }
  }

  private void bindFilterDef(FullTextFilterDef defAnn, XClass mappedXClass) {
    if ( filterDefinitions.containsKey( defAnn.name() ) ) {
      throw new SearchException("Multiple definition of @FullTextFilterDef.name=" + defAnn.name() + ": "
          + mappedXClass.getName() );
    }

    FilterDef filterDef = new FilterDef(defAnn);
    try {
      filterDef.getImpl().newInstance();
    }
    catch (IllegalAccessException e) {
      throw new SearchException("Unable to create Filter class: " + filterDef.getImpl().getName(), e);
    }
    catch (InstantiationException e) {
      throw new SearchException("Unable to create Filter class: " + filterDef.getImpl().getName(), e);
    }
    for ( Method method : filterDef.getImpl().getMethods() ) {
      if ( method.isAnnotationPresent( Factory.class ) ) {
        if ( filterDef.getFactoryMethod() != null ) {
          throw new SearchException("Multiple @Factory methods found" + defAnn.name() + ": "
              + filterDef.getImpl().getName() + "." + method.getName() );
        }
        if ( !method.isAccessible() ) method.setAccessible( true );
        filterDef.setFactoryMethod( method );
      }
      if ( method.isAnnotationPresent( Key.class ) ) {
        if ( filterDef.getKeyMethod() != null ) {
          throw new SearchException("Multiple @Key methods found" + defAnn.name() + ": "
              + filterDef.getImpl().getName() + "." + method.getName() );
        }
        if ( !method.isAccessible() ) method.setAccessible( true );
        filterDef.setKeyMethod( method );
      }
View Full Code Here

  }

  public void optimize(Class entityType) {
    if (barrier != 0) {} //read barrier
    if ( ! getDocumentBuilders().containsKey( entityType ) ) {
      throw new SearchException("Entity not indexed: " + entityType);
    }
    List<LuceneWork> queue = new ArrayList<LuceneWork>(1);
    queue.add( new OptimizeLuceneWork( entityType ) );
    getBackendQueueProcessorFactory().getProcessor( queue ).run();
  }
View Full Code Here

  }

  public Analyzer getAnalyzer(String name) {
    if (barrier != 0) {} //read barrier
    final Analyzer analyzer = analyzers.get( name );
    if ( analyzer == null) throw new SearchException( "Unknown Analyzer definition: " + name);
    return analyzer;
  }
View Full Code Here

      try {
        Class filterCachingStrategyClass = org.hibernate.annotations.common.util.ReflectHelper.classForName( impl, SearchFactoryImpl.class );
        filterCachingStrategy = (FilterCachingStrategy) filterCachingStrategyClass.newInstance();
      }
      catch (ClassNotFoundException e) {
        throw new SearchException( "Unable to find filterCachingStrategy class: " + impl, e );
      }
      catch (IllegalAccessException e) {
        throw new SearchException( "Unable to instantiate filterCachingStrategy class: " + impl, e );
      }
      catch (InstantiationException e) {
        throw new SearchException( "Unable to instantiate filterCachingStrategy class: " + impl, e );
      }
    }
    filterCachingStrategy.initialize( properties );
    return filterCachingStrategy;
  }
View Full Code Here

      reader = IndexReader.open( directory, false );
      log.trace( "IndexReader opened" );
    }
    catch ( IOException e ) {
      reader = null;
      throw new SearchException( "Unable to open IndexReader on directory " + directory, e );
    }
    return reader;
  }
View Full Code Here

      try {
        toClose.close();
        log.trace( "IndexReader closed" );
      }
      catch ( IOException e ) {
        throw new SearchException( "Exception while closing IndexReader", e );
      }
    }
    else {
      throw new AssertionFailure( "No IndexReader open to close." );
    }
View Full Code Here

      indexingParams.applyToWriter( writer, batchmode );
      log.trace( "IndexWriter opened" );
    }
    catch ( IOException e ) {
      writer = null;
      throw new SearchException( "Unable to open IndexWriter", e );
    }
    return writer;
  }
View Full Code Here

      try {
        writer.commit();
        log.trace( "Index changes commited." );
      }
      catch ( IOException e ) {
        throw new SearchException( "Exception while commiting index changes", e );
      }
    }
    else {
      throw new AssertionFailure( "No open IndexWriter to commit changes." );
    }
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.