Package org.hibernate.search

Examples of org.hibernate.search.FullTextSession


        }
    ftSession.flushToIndexes();
    }

    private void purge() {
        FullTextSession ftSession = org.hibernate.search.Search.getFullTextSession((Session) em.getDelegate());
        ftSession.purgeAll(Book.class);
    }
View Full Code Here


  public void index(String entity) {
    Class<?> clazz = getEntityClass( entity );

    SessionFactory factory = getSessionFactory();
    Session session = factory.openSession();
    FullTextSession fulltextSession = Search.getFullTextSession( session );
    try {
      fulltextSession.createIndexer( clazz )
          .batchSizeToLoadObjects( batchSize )
          .cacheMode( CacheMode.NORMAL )
          .threadsToLoadObjects( numberOfObjectLoadingThreads )
          .startAndWait();
    }
View Full Code Here

  public void optimize(String entity) {
    Class<?> clazz = getEntityClass( entity );

    SessionFactory factory = getSessionFactory();
    Session session = factory.openSession();
    FullTextSession fullTextSession = Search.getFullTextSession( session );
    fullTextSession.beginTransaction();
    fullTextSession.getSearchFactory().optimize( clazz );
    fullTextSession.getTransaction().commit();
    session.close();
  }
View Full Code Here

  public void purge(String entity) {
    Class<?> clazz = getEntityClass( entity );

    SessionFactory factory = getSessionFactory();
    Session session = factory.openSession();
    FullTextSession fullTextSession = Search.getFullTextSession( session );
    fullTextSession.beginTransaction();
    fullTextSession.purgeAll( clazz );
    fullTextSession.getTransaction().commit();
    session.close();
  }
View Full Code Here

    return ftSession;
  }

  @Override
  public FullTextQuery createFullTextQuery(org.apache.lucene.search.Query luceneQuery, Class<?>... entities) {
    FullTextSession ftSession = getFullTextSession();
    return new FullTextQueryImpl( ftSession.createFullTextQuery( luceneQuery, entities ), ftSession );
  }
View Full Code Here

    emf = config.buildEntityManagerFactory();
    em = emf.createEntityManager();
  }

  private void index() {
    FullTextSession ftSession = org.hibernate.search.Search.getFullTextSession( (Session) em.getDelegate() );
    try {
      ftSession.createIndexer().startAndWait();
    }
    catch ( InterruptedException e ) {
      log.error( "Was interrupted during indexing", e );
    }
  }
View Full Code Here

      log.error( "Was interrupted during indexing", e );
    }
  }

  private void purge() {
    FullTextSession ftSession = org.hibernate.search.Search.getFullTextSession( (Session) em.getDelegate() );
    ftSession.purgeAll( Book.class );
    ftSession.flushToIndexes();
    ftSession.close();
    emf.close();
  }
View Full Code Here

            // Search in all indexed fields

            IndexReaderAccessor readerAccessor = null;
            IndexReader reader = null;
            try {
                FullTextSession txtSession = Search.getFullTextSession(sess);

                // obtain analyzer to parse the query:
                Analyzer analyzer;
                if (searchedEntity == null) {
                    analyzer = defaultAnalyzer;
                } else {
                    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) {
View Full Code Here

     *
     * @param clazz the class
     * @param sess the hibernate session
     */
    public static void reindex(Class clazz, Session sess) {
        FullTextSession txtSession = Search.getFullTextSession(sess);
        MassIndexer massIndexer = txtSession.createIndexer(clazz);
        try {
            massIndexer.startAndWait();
        } catch (InterruptedException e) {
            log.error("mass reindexing interrupted: " + e.getMessage());
        } finally {
            txtSession.flushToIndexes();
        }
    }
View Full Code Here

     *
     * @param async true if the reindexing will be done as a background thread
     * @param sess the hibernate session
     */
    public static void reindexAll(boolean async, Session sess) {
        FullTextSession txtSession = Search.getFullTextSession(sess);
        MassIndexer massIndexer = txtSession.createIndexer();
        massIndexer.purgeAllOnStart(true);
        try {
            if (!async) {
                massIndexer.startAndWait();
            } else {
                massIndexer.start();
            }
        } catch (InterruptedException e) {
            log.error("mass reindexing interrupted: " + e.getMessage());
        } finally {
            txtSession.flushToIndexes();
        }
    }
View Full Code Here

TOP

Related Classes of org.hibernate.search.FullTextSession

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.