Package org.hibernate.search

Examples of org.hibernate.search.FullTextSession.index()


    private void index() {
      em.getTransaction().begin();
        FullTextSession ftSession = org.hibernate.search.Search.getFullTextSession((Session) em.getDelegate());
        List<Book> results = ftSession.createCriteria(Book.class).list();
        for (Object obj : results) {
            ftSession.index(obj);
        }
        em.getTransaction().commit();
    }

    private void purge() {
View Full Code Here


    tx = s.beginTransaction();
    ScrollableResults results = s.createCriteria( Email.class ).scroll( ScrollMode.FORWARD_ONLY );
    int index = 0;
    while ( results.next() ) {
      index++;
      s.index( results.get( 0 ) );
      if ( index % 5 == 0 ) s.clear();
    }
    tx.commit();
    s.clear();
    tx = s.beginTransaction();
View Full Code Here

    parser = new QueryParser( "id", new StopAnalyzer() );
    result = s.createFullTextQuery( parser.parse( "body:write" ) ).list();
    assertEquals( 0, result.size() );
    result = s.createCriteria( Email.class ).list();
    for (int i = 0; i < loop / 2; i++)
      s.index( result.get( i ) );
    tx.commit(); //do the process
    s.index( result.get( loop / 2 ) ); //do the process out of tx
    tx = s.beginTransaction();
    for (int i = loop / 2 + 1; i < loop; i++)
      s.index( result.get( i ) );
View Full Code Here

    assertEquals( 0, result.size() );
    result = s.createCriteria( Email.class ).list();
    for (int i = 0; i < loop / 2; i++)
      s.index( result.get( i ) );
    tx.commit(); //do the process
    s.index( result.get( loop / 2 ) ); //do the process out of tx
    tx = s.beginTransaction();
    for (int i = loop / 2 + 1; i < loop; i++)
      s.index( result.get( i ) );
    tx.commit(); //do the process
    s.close();
View Full Code Here

      s.index( result.get( i ) );
    tx.commit(); //do the process
    s.index( result.get( loop / 2 ) ); //do the process out of tx
    tx = s.beginTransaction();
    for (int i = loop / 2 + 1; i < loop; i++)
      s.index( result.get( i ) );
    tx.commit(); //do the process
    s.close();

    s = Search.getFullTextSession( openSession() );
    tx = s.beginTransaction();
View Full Code Here

    s = Search.getFullTextSession( openSession() );
    tx = s.beginTransaction();
    //object never indexed
    Email email = (Email) s.get( Email.class, Long.valueOf( loop + 1 ) );
    s.index( email );
    tx.commit();
    s.close();

    //check non indexed object get indexed by s.index
    s = new FullTextSessionImpl( openSession() );
View Full Code Here

    s.close();

    s = openSession();
    ent = (Entite) s.get( Entite.class, ent.getId() );
    session = Search.getFullTextSession( s );
    session.index( ent );
    s.close();

    s = openSession();
    session = Search.getFullTextSession( s );
    luceneQuery = new TermQuery( new Term( "categorie.nom", "livre" ) );
View Full Code Here

    s = openSession();
    Iterator it = s.createQuery( "from Entite where id = :id").setParameter( "id", ent.getId() ).iterate();
    session = Search.getFullTextSession( s );
    while ( it.hasNext() ) {
      ent = (Entite) it.next();
      session.index( ent );
    }
    s.close();

    s = openSession();
    session = Search.getFullTextSession( s );
View Full Code Here

    ScrollableResults results = s.createCriteria( Email.class ).scroll( ScrollMode.FORWARD_ONLY );
    int index = 0;
    while ( results.next() ) {
      index++;
      final Email o = (Email) results.get( 0 );
      s.index( o );
      if ( index % 5 == 0 ) {
        s.flushToIndexes();
        s.clear();
      }
    }
View Full Code Here

    tx = s.beginTransaction();
    ScrollableResults results = s.createCriteria( Email.class ).scroll( ScrollMode.FORWARD_ONLY );
    int index = 0;
    while ( results.next() ) {
      index++;
      s.index( results.get( 0 ) );
      if ( index % 5 == 0 ) {
        s.clear();
      }
    }
    tx.commit(); // if you get a LazyInitializationException, that's because we clear() the session in the loop.. it only works with a batch size of 5 (the point of the test)
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.