Package org.hibernate.search.engine.spi

Examples of org.hibernate.search.engine.spi.SearchFactoryImplementor


    * @param cache the cache containing the indexes
    * @param types vararg listing the types the indexing engine should know
    */
   private void assertIndexingKnows(Cache<Object, Object> cache, Class... types) {
      ComponentRegistry cr = cache.getAdvancedCache().getComponentRegistry();
      SearchFactoryImplementor searchFactoryIntegrator = (SearchFactoryImplementor) cr.getComponent(SearchFactoryIntegrator.class);
      Assert.assertNotNull(searchFactoryIntegrator);
      Map<Class<?>, EntityIndexBinder> indexBindingForEntity = searchFactoryIntegrator.getIndexBindingForEntity();
      Assert.assertNotNull(indexBindingForEntity);
      Set<Class<?>> keySet = indexBindingForEntity.keySet();
      Assert.assertEquals(types.length, keySet.size());
      Assert.assertTrue(keySet.containsAll(Arrays.asList(types)));
   }
View Full Code Here


  public <T> void purgeAll(Class<T> entityType) {
    purge( entityType, null );
  }

  public void flushToIndexes() {
    SearchFactoryImplementor searchFactoryImplementor = getSearchFactoryImplementor();
    searchFactoryImplementor.getWorker().flushWorks( transactionContext );
  }
View Full Code Here

      throw new IllegalArgumentException( "Entity to index should not be null" );
    }

    Class<?> clazz = HibernateHelper.getClass( entity );
    //TODO cache that at the FTSession level
    SearchFactoryImplementor searchFactoryImplementor = getSearchFactoryImplementor();
    //not strictly necessary but a small optimization
    if ( searchFactoryImplementor.getIndexBindingForEntity( clazz ) == null ) {
      String msg = "Entity to index is not an @Indexed entity: " + entity.getClass().getName();
      throw new IllegalArgumentException( msg );
    }
    Serializable id = session.getIdentifier( entity );
    Work<T> work = new Work<T>( entity, id, WorkType.INDEX );
    searchFactoryImplementor.getWorker().performWork( work, transactionContext );

    //TODO
    //need to add elements in a queue kept at the Session level
    //the queue will be processed by a Lucene(Auto)FlushEventListener
    //note that we could keep this queue somewhere in the event listener in the mean time but that requires
View Full Code Here

    purge( entityType, null );
  }

  @Override
  public void flushToIndexes() {
    SearchFactoryImplementor searchFactoryImplementor = getSearchFactoryImplementor();
    searchFactoryImplementor.getWorker().flushWorks( transactionContext );
  }
View Full Code Here

      throw new IllegalArgumentException( "Entity to index should not be null" );
    }

    Class<?> clazz = HibernateHelper.getClass( entity );
    //TODO cache that at the FTSession level
    SearchFactoryImplementor searchFactoryImplementor = getSearchFactoryImplementor();
    //not strictly necessary but a small optimization
    if ( searchFactoryImplementor.getIndexBinding( clazz ) == null ) {
      String msg = "Entity to index is not an @Indexed entity: " + entity.getClass().getName();
      throw new IllegalArgumentException( msg );
    }
    Serializable id = session.getIdentifier( entity );
    Work<T> work = new Work<T>( entity, id, WorkType.INDEX );
    searchFactoryImplementor.getWorker().performWork( work, transactionContext );

    //TODO
    //need to add elements in a queue kept at the Session level
    //the queue will be processed by a Lucene(Auto)FlushEventListener
    //note that we could keep this queue somewhere in the event listener in the mean time but that requires
View Full Code Here

    MassIndexerFactory factory;
    Properties properties = getSearchFactoryImplementor().getConfigurationProperties();
    String factoryClassName = properties.getProperty( MassIndexerFactory.MASS_INDEXER_FACTORY_CLASSNAME );

    if ( factoryClassName != null ) {
      SearchFactoryImplementor searchFactoryImplementor = getSearchFactoryImplementor();
      ServiceManager serviceManager = searchFactoryImplementor.getServiceManager();
      factory = ClassLoaderHelper.instanceFromName(
          MassIndexerFactory.class, factoryClassName, "Mass indexer factory", serviceManager
      );
    }
    else {
View Full Code Here

  }

  private final MutableSearchFactoryState factoryState = new MutableSearchFactoryState();

  public SearchFactoryImplementor buildSearchFactory() {
    SearchFactoryImplementor searchFactoryImplementor;
    if ( rootFactory == null ) {
      if ( classes.size() > 0 ) {
        throw new SearchException( "Cannot add a class if the original SearchFactory is not passed" );
      }
      searchFactoryImplementor = buildNewSearchFactory();
View Full Code Here

      cache.put(1, wrapper1);   //todo how do we index if the key is a byte array?
      cache.put(2, wrapper2);

      SearchManager sm = Search.getSearchManager(cache);

      SearchFactoryImplementor searchFactory = (SearchFactoryImplementor) sm.getSearchFactory();
      assertNotNull(searchFactory.getIndexManagerHolder().getIndexManager(ProtobufValueWrapper.class.getName()));

      Query luceneQuery = sm.buildQueryBuilderForClass(ProtobufValueWrapper.class)
            .get()
            .keyword()
            .onField("name")
            .ignoreFieldBridge()
            .ignoreAnalyzer()
            .matching("Adrian")
            .createQuery();

      List<Object> list = sm.getQuery(luceneQuery).list();
      assertEquals(1, list.size());

      // an alternative approach ...

      Query luceneQuery2 = searchFactory.buildQueryBuilder().forEntity(ProtobufValueWrapper.class).get()
            .keyword()
            .onField("name")
            .ignoreFieldBridge()
            .ignoreAnalyzer()
            .matching("Adrian")
            .createQuery();

      List<EntityInfo> queryEntityInfos = searchFactory.createHSQuery().luceneQuery(luceneQuery2)
            .targetedEntities(Collections.<Class<?>>singletonList(ProtobufValueWrapper.class))
            .projection("surname")
            .queryEntityInfos();

      assertEquals(1, queryEntityInfos.size());
View Full Code Here

    stream.close();
    return terms;
  }

  static DocumentBuilderIndexedEntity<?> getDocumentBuilder(QueryBuildingContext queryContext) {
    final SearchFactoryImplementor factory = queryContext.getFactory();
    final Class<?> type = queryContext.getEntityType();
    EntityIndexBinding indexBinding = factory.getIndexBinding( type );
    if ( indexBinding == null ) {
      throw new AssertionFailure( "Class is not indexed: " + type );
    }
    return indexBinding.getDocumentBuilder();
  }
View Full Code Here

    }
    final ObjectMessage objectMessage = (ObjectMessage) message;
    final String indexName;
    final List<LuceneWork> queue;
    final IndexManager indexManager;
    SearchFactoryImplementor factory = getSearchFactory().unwrap( SearchFactoryImplementor.class );
    try {
      indexName = objectMessage.getStringProperty( Environment.INDEX_NAME_JMS_PROPERTY );
      indexManager = factory.getIndexManagerHolder().getIndexManager( indexName );
      if ( indexManager == null ) {
        log.messageReceivedForUndefinedIndex( indexName );
        return;
      }
      queue = indexManager.getSerializer().toLuceneWorks( (byte[]) objectMessage.getObject() );
View Full Code Here

TOP

Related Classes of org.hibernate.search.engine.spi.SearchFactoryImplementor

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.