Package org.hibernate.search.engine.spi

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


  }

  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


    stream.close();
    return terms;
  }

  static DocumentBuilderIndexedEntity<?> getDocumentBuilder(QueryBuildingContext queryContext) {
    final SearchFactoryImplementor factory = queryContext.getFactory();
    final Class<?> type = queryContext.getEntityType();
    EntityIndexBinder indexBinding = factory.getIndexBindingForEntity( type );
    if ( indexBinding == null ) {
      throw new AssertionFailure( "Class in not indexed: " + type );
    }
    return indexBinding.getDocumentBuilder();
  }
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();
    EntityIndexBinder<?> indexBinding = factory.getIndexBindingForEntity( type );
    if ( indexBinding == null ) {
      throw new AssertionFailure( "Class in not indexed: " + type );
    }
    return indexBinding.getDocumentBuilder();
  }
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

      assertEquals("A Person's Name", p.getName());
      assertEquals("A paragraph containing some text", p.getBlurb());
      assertEquals(75, p.getAge());

      SearchManager queryFactory = Search.getSearchManager(indexedCache);
      SearchFactoryImplementor searchImpl = (SearchFactoryImplementor) queryFactory.getSearchFactory();
      IndexManager[] indexManagers = searchImpl.getIndexBinding(Person.class).getIndexManagers();
      assert indexManagers != null && indexManagers.length == 1;
      DirectoryBasedIndexManager directory = (DirectoryBasedIndexManager)indexManagers[0];
      DirectoryProvider directoryProvider = directory.getDirectoryProvider();
      assert directoryProvider instanceof RAMDirectoryProvider : "configuration properties where ignored";
   }
View Full Code Here

public class TuningOptionsAppliedTest {

   public void verifyFSDirectoryOptions() throws IOException {
      EmbeddedCacheManager embeddedCacheManager = TestCacheManagerFactory.fromXml("nrt-performance-writer.xml");
      try {
         SearchFactoryImplementor si = extractSearchFactoryImplementor(embeddedCacheManager);
         NRTIndexManager nrti = verifyShardingOptions(si, 6);
         verifyIndexWriterOptions(nrti, 220, 4096, 30);
         verifyUsesFSDirectory(nrti);
      }
      finally {
View Full Code Here

   }

   public void verifyInfinispanDirectoryOptions() throws IOException, IllegalArgumentException, IllegalAccessException, SecurityException, NoSuchFieldException {
      EmbeddedCacheManager embeddedCacheManager = TestCacheManagerFactory.fromXml("nrt-performance-writer-infinispandirectory.xml");
      try {
         SearchFactoryImplementor si = extractSearchFactoryImplementor(embeddedCacheManager);
         NRTIndexManager nrti = verifyShardingOptions(si, 6);
         verifyIndexWriterOptions(nrti, 64, 1024, 30);
         verifyUsesInfinispanDirectory(nrti, 128000, embeddedCacheManager);
         //Make sure to close the Indexed cache before those storing the index:
         embeddedCacheManager.getCache("Indexed").stop();
View Full Code Here

    * @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);
      assertNotNull(searchFactoryIntegrator);
      Map<Class<?>, EntityIndexBinding> indexBindingForEntity = searchFactoryIntegrator.getIndexBindings();
      assertNotNull(indexBindingForEntity);
      Set<Class<?>> keySet = indexBindingForEntity.keySet();
      assertEquals(types.length, keySet.size());
      assertTrue(keySet.containsAll(Arrays.asList(types)));
   }
View Full Code Here

   }

   private boolean isMasterNode(Cache<?,?> cache) {
      //Implicitly verifies the components are setup as configured by casting:
      SearchManager searchManager = Search.getSearchManager(cache);
      SearchFactoryImplementor searchFactory = (SearchFactoryImplementor) searchManager.getSearchFactory();
      InfinispanIndexManager indexManager = (InfinispanIndexManager) searchFactory.getIndexManagerHolder().getIndexManager("person");
      return indexManager.isMasterLocal();
   }
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.