Package org.hibernate.search

Examples of org.hibernate.search.FullTextQuery.list()


    FullTextSession fullTextSession = Search.getFullTextSession( openSession() );
    Transaction tx = fullTextSession.beginTransaction();

    Query luceneQuery = new MatchAllDocsQuery();
    FullTextQuery fullTextQuery = fullTextSession.createFullTextQuery( luceneQuery, TestEntity.class );
    int hitCount = fullTextQuery.list().size();
    assertEquals( "Wrong hit count", 100, hitCount );

    tx.commit();
    fullTextSession.close();
View Full Code Here


    Query query = queryBuilder.all().createQuery();
    FieldSelectorLeakingReaderProvider.resetFieldSelector();
    FullTextSession fullTextSession = Search.getFullTextSession( session );
    FullTextQuery fullTextQuery = fullTextSession.createFullTextQuery( query, Location.class );
    fullTextQuery.setSort( new Sort( new SortField( "description", SortField.Type.STRING ) ) ); // to avoid loading in document order -- too easy
    List<Location> locations = fullTextQuery.list();
    FieldSelectorLeakingReaderProvider.assertFieldSelectorDisabled();
    Assert.assertEquals( NUM_LOCATIONS, locations.size() );
    for ( Location location : locations ) {
      int id = location.getId();
      Assert.assertEquals( String.valueOf( id ) + "42", location.getDescription() );
View Full Code Here

    Query query = queryBuilder.all().createQuery();
    FullTextSession fullTextSession = builder.openFullTextSession();
    Transaction transaction = fullTextSession.beginTransaction();
    FieldSelectorLeakingReaderProvider.resetFieldSelector();
    FullTextQuery fullTextQuery = fullTextSession.createFullTextQuery( query );
    List list = fullTextQuery.list();
    Assert.assertEquals( 2, list.size() );
    FieldSelectorLeakingReaderProvider.assertFieldSelectorEnabled( expectedLoadedFields );
    transaction.commit();
    fullTextSession.close();
  }
View Full Code Here

  private void assertElmoIndexed(FullTextSession fullTextSession, boolean indexed) {
    Query matchAllQuery = new MatchAllDocsQuery();
    FullTextQuery query = fullTextSession.createFullTextQuery( matchAllQuery, Muppet.class );
    if ( indexed ) {
      assertEquals( "Elmo should be there", 1, query.list().size() );
      Muppet muppet = (Muppet) query.list().get( 0 );
      assertEquals( "Index muppet is not Elmo", "Elmo", muppet.getName() );
    }
    else {
      assertEquals( "Elmo should not be there", 0, query.list().size() );
View Full Code Here

  private void assertElmoIndexed(FullTextSession fullTextSession, boolean indexed) {
    Query matchAllQuery = new MatchAllDocsQuery();
    FullTextQuery query = fullTextSession.createFullTextQuery( matchAllQuery, Muppet.class );
    if ( indexed ) {
      assertEquals( "Elmo should be there", 1, query.list().size() );
      Muppet muppet = (Muppet) query.list().get( 0 );
      assertEquals( "Index muppet is not Elmo", "Elmo", muppet.getName() );
    }
    else {
      assertEquals( "Elmo should not be there", 0, query.list().size() );
    }
View Full Code Here

      assertEquals( "Elmo should be there", 1, query.list().size() );
      Muppet muppet = (Muppet) query.list().get( 0 );
      assertEquals( "Index muppet is not Elmo", "Elmo", muppet.getName() );
    }
    else {
      assertEquals( "Elmo should not be there", 0, query.list().size() );
    }
  }

  public class AssertingMassIndexerProgressMonitor implements MassIndexerProgressMonitor {
    private final AtomicLong totalCount = new AtomicLong();
View Full Code Here

    int byResultSize = 0;
    FullTextSession fullTextSession = builder.openFullTextSession();
    try {
      Transaction tx = fullTextSession.beginTransaction();
      FullTextQuery fullTextQuery = fullTextSession.createFullTextQuery( findAll, types );
      bySize = fullTextQuery.list().size();
      byResultSize = fullTextQuery.getResultSize();
      tx.commit();
    }
    finally {
      fullTextSession.close();
View Full Code Here

      FullTextQuery fullTextQuery = fullTextSession.createFullTextQuery( q );
      int resultSize = fullTextQuery.getResultSize();
      assertEquals( 1, resultSize );

      @SuppressWarnings("unchecked")
      List<Person> list = fullTextQuery.list();
      assertEquals( 1, list.size() );
      transaction.commit();
    }
    finally {
      fullTextSession.close();
View Full Code Here

      FullTextQuery fullTextQuery = fullTextSession.createFullTextQuery( q );
      int resultSize = fullTextQuery.getResultSize();
      assertEquals( 1, resultSize );

      @SuppressWarnings("unchecked")
      List<Root> list = fullTextQuery.list();
      assertEquals( 1, list.size() );
      transaction.commit();
    }
    finally {
      fullTextSession.close();
View Full Code Here

    FullTextQuery fullTextQuery = fullTextSession.createFullTextQuery(
        queryBuilder.keyword().onField( field ).matching( value ).createQuery(),
        IndexedEntity.class );

    return (List<IndexedEntity>) fullTextQuery.list();
  }

  @Override
  protected Class<?>[] getAnnotatedClasses() {
    return new Class[] { IndexedEntity.class, CollectionItem.class };
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.