Package org.hibernate.search

Examples of org.hibernate.search.SearchFactory


                    analyzer = fullTextEntityManager.getSearchFactory().getAnalyzer(searchedEntity);
                }

                // search on all indexed fields: generate field list, removing internal hibernate search field name: _hibernate_class
                // TODO: possible improvement: cache the fields of each entity
                SearchFactory searchFactory = fullTextEntityManager.getSearchFactory();
                readerAccessor = searchFactory.getIndexReaderAccessor();
                reader = readerAccessor.open(searchedEntity);
                Collection<String> fieldNames = new HashSet<>();
                for (FieldInfo fieldInfo : ReaderUtil.getMergedFieldInfos(reader)) {
                    if (fieldInfo.isIndexed) {
                        fieldNames.add(fieldInfo.name);
View Full Code Here


  
   public void setCache(Cache<?, ?> cache, EmbeddedCacheManager cacheManager){
     this.cacheManager = cacheManager;
      this.cache = cache;
      SearchManager searchManager = Search.getSearchManager(cache);
      SearchFactory searchFactory = searchManager.getSearchFactory();
      searchFactoryImplementor = (SearchFactoryImplementor) searchFactory;
      queryInterceptor = ComponentRegistryUtils.getQueryInterceptor(cache);
   }
View Full Code Here

  
   public void setCache(Cache<?, ?> cache, EmbeddedCacheManager cacheManager){
     this.cacheManager = cacheManager;
      this.cache = cache;
      SearchManager searchManager = Search.getSearchManager(cache);
      SearchFactory searchFactory = searchManager.getSearchFactory();
      searchFactoryImplementor = (SearchFactoryImplementor) searchFactory;
      queryInterceptor = ComponentRegistryUtils.getQueryInterceptor(cache);
   }
View Full Code Here

                    analyzer = txtSession.getSearchFactory().getAnalyzer(searchedEntity);
                }

                // search on all indexed fields: generate field list, removing internal hibernate search field name: _hibernate_class
                // TODO: possible improvement: cache the fields of each entity
                SearchFactory searchFactory = txtSession.getSearchFactory();
                readerAccessor = searchFactory.getIndexReaderAccessor();
                reader = readerAccessor.open(searchedEntity);
                Collection<String> fieldNames = new HashSet<>();
                for (FieldInfo fieldInfo : ReaderUtil.getMergedFieldInfos(reader)) {
                    if (fieldInfo.isIndexed) {
                        fieldNames.add(fieldInfo.name);
View Full Code Here

  public static void performWorkList(FullTextEntityManager fullTextEntityManager, WorkList workListEntity) {
    WorkListDAO workListDAO = new WorkListDAO();
    DirectoryDAO directoryDAO = new DirectoryDAO();

    SearchFactory searchFactory = fullTextEntityManager.getSearchFactory();
   
    Directory directory = directoryDAO.findByKey(workListEntity.getKey().getParent());
   
    IndexManager indexManager = getIndexManager(searchFactory, directory.getName());
    LuceneWorkSerializer serializer = indexManager.getSerializer();
View Full Code Here

      s.clear();
      Transaction tx = s.beginTransaction();

      // Here's how to get a reader from a FullTextSession
      SearchFactory searchFactory = s.getSearchFactory();
      DirectoryProvider provider = searchFactory.getDirectoryProviders(ElectricalProperties.class)[0];
      ReaderProvider readerProvider = searchFactory.getReaderProvider();
      IndexReader reader = readerProvider.openReader(provider);

      /**
       * Since there are so many combinations of results here, we are only going
       * to assert a few. - J.G.
View Full Code Here

      s.clear();

      tx = s.beginTransaction();

      // Here's how to get a reader from a FullTextSession
      SearchFactory searchFactory = s.getSearchFactory();
      DirectoryProvider provider = searchFactory.getDirectoryProviders(Employee.class)[0];
      ReaderProvider readerProvider = searchFactory.getReaderProvider();
      IndexReader reader = readerProvider.openReader(provider);

      TermPositionVector vector = (TermPositionVector) reader.getTermFreqVector(0, "dept");
      assertNull("should not find a term position vector", vector);
View Full Code Here

    s.close();
  }

  public void testScopedAnalyzersFromSearchFactory() throws Exception {
    FullTextSession session = Search.getFullTextSession( openSession() );
    SearchFactory searchFactory = session.getSearchFactory();
    Analyzer analyzer = searchFactory.getAnalyzer( MyEntity.class );

    // you can pass what so ever into the analysis since the used analyzers are
    // returning the same tokens all the time. We just want to make sure that
    // the right analyzers are used.
    Token[] tokens = AnalyzerUtils.tokensFromAnalysis( analyzer, "entity", "" );
    AnalyzerUtils.assertTokensEqual( tokens, new String[] { "alarm", "dog", "performance" } );

    tokens = AnalyzerUtils.tokensFromAnalysis( analyzer, "property", "" );
    AnalyzerUtils.assertTokensEqual( tokens, new String[] { "sound", "cat", "speed" } );

    tokens = AnalyzerUtils.tokensFromAnalysis( analyzer, "field", "" );
    AnalyzerUtils.assertTokensEqual( tokens, new String[] { "music", "elephant", "energy" } );

    tokens = AnalyzerUtils.tokensFromAnalysis( analyzer, "component.componentProperty", "" );
    AnalyzerUtils.assertTokensEqual( tokens, new String[] { "noise", "mouse", "light" } );

    // test border cases
    try {
      searchFactory.getAnalyzer( ( Class ) null );
    }
    catch ( IllegalArgumentException iae ) {
      log.debug( "success" );
    }

    try {
      searchFactory.getAnalyzer( String.class );
    }
    catch ( IllegalArgumentException iae ) {
      log.debug( "success" );
    }
View Full Code Here

    s.close();
  }

  public void testScopedAnalyzersFromSearchFactory() throws Exception {
    FullTextSession session = Search.getFullTextSession( openSession() );
    SearchFactory searchFactory = session.getSearchFactory();
    Analyzer analyzer = searchFactory.getAnalyzer( MyEntity.class );

    // you can pass what so ever into the analysis since the used analyzers are
    // returning the same tokens all the time. We just want to make sure that
    // the right analyzers are used.
    Token[] tokens = AnalyzerUtils.tokensFromAnalysis( analyzer, "entity", "" );
    AnalyzerUtils.assertTokensEqual( tokens, new String[] { "alarm", "dog", "performance" } );

    tokens = AnalyzerUtils.tokensFromAnalysis( analyzer, "property", "" );
    AnalyzerUtils.assertTokensEqual( tokens, new String[] { "sound", "cat", "speed" } );

    tokens = AnalyzerUtils.tokensFromAnalysis( analyzer, "field", "" );
    AnalyzerUtils.assertTokensEqual( tokens, new String[] { "music", "elephant", "energy" } );

    tokens = AnalyzerUtils.tokensFromAnalysis( analyzer, "component.componentProperty", "" );
    AnalyzerUtils.assertTokensEqual( tokens, new String[] { "noise", "mouse", "light" } );

    // test border cases
    try {
      searchFactory.getAnalyzer( ( Class ) null );
    }
    catch ( IllegalArgumentException iae ) {
      log.debug( "success" );
    }

    try {
      searchFactory.getAnalyzer( String.class );
    }
    catch ( IllegalArgumentException iae ) {
      log.debug( "success" );
    }
View Full Code Here

   private QueryInterceptor queryInterceptor;
  
   public void setCache(Cache<?, ?> cache){
      this.cache = cache;
      SearchManager searchManager = Search.getSearchManager(cache);
      SearchFactory searchFactory = searchManager.getSearchFactory();
      searchFactoryImplementor = (SearchFactoryImplementor) searchFactory;
      queryInterceptor = ComponentRegistryUtils.getQueryInterceptor(cache);
   }
View Full Code Here

TOP

Related Classes of org.hibernate.search.SearchFactory

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.