Package org.hibernate.search

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


    assertEquals( 2, fts.createFullTextQuery( q ).getResultSize() );
    assertEquals( 2, fts.createFullTextQuery( q, Detective.class, Suspect.class ).getResultSize() );
   
    FullTextQuery detectiveQuery = fts.createFullTextQuery( q, Detective.class );
    assertEquals( 1, detectiveQuery.getResultSize() );
    assertTrue( detectiveQuery.list().get(0) instanceof Detective );
   
    FullTextQuery suspectQuery = fts.createFullTextQuery( q, Suspect.class );
    assertEquals( 1, suspectQuery.getResultSize() );
    assertTrue( suspectQuery.list().get(0) instanceof Suspect );
   
View Full Code Here


    assertEquals( 1, detectiveQuery.getResultSize() );
    assertTrue( detectiveQuery.list().get(0) instanceof Detective );
   
    FullTextQuery suspectQuery = fts.createFullTextQuery( q, Suspect.class );
    assertEquals( 1, suspectQuery.getResultSize() );
    assertTrue( suspectQuery.list().get(0) instanceof Suspect );
   
    assertEquals( 2, fts.createFullTextQuery( q ).getResultSize() );
    assertEquals( 2, fts.createFullTextQuery( q, Detective.class, Suspect.class ).getResultSize() );
   
    tx.commit();
View Full Code Here

    tx = s.beginTransaction();
    String searchQuery = "Joe";
    QueryParser parser = new QueryParser( TestConstants.getTargetLuceneVersion(), "Content", TestConstants.standardAnalyzer );
    Query luceneQuery = parser.parse( searchQuery );
    FullTextQuery query = s.createFullTextQuery( luceneQuery );
    List results = query.list();
    assertTrue( "We should have a hit", results.size() == 1 );
    tx.commit();

    // Now try to delete
    tx = s.beginTransaction();
View Full Code Here

  private List<EntityExtendingMappedSuperclassWithCollectionField> searchEntityByCollectionValue(String value) {
    FullTextQuery query = fullTextSession.createFullTextQuery(
        new TermQuery( new Term( "collection", value ) ),
        EntityExtendingMappedSuperclassWithCollectionField.class
    );
    return query.list();
  }

  @Override
  protected Class<?>[] getAnnotatedClasses() {
    return new Class[] {
View Full Code Here

      query = getQuery( "green",  parser, s );
      random.nextInt( query.getResultSize() - 15 );
      query.setFirstResult( random.nextInt( query.getResultSize() - 15 ) );
      query.setMaxResults( 10 );
      query.list();
      tx.commit();
      s.close();

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

      query = getQuery( "thief",  parser, s );
      int firstResult = random.nextInt( query.getResultSize() - 15 );
      query.setFirstResult( firstResult );
      query.setMaxResults( 10 );
      List result = query.list();
      Object object = result.get(0);
      if (insert && object instanceof Detective) {
        Detective detective = (Detective) object;
        detective.setPhysicalDescription( detective.getPhysicalDescription() + " Eye" + firstResult );
      }
View Full Code Here

      query = getQuery( "london",  parser, s );
      random.nextInt( query.getResultSize() - 15 );
      query.setFirstResult( random.nextInt( query.getResultSize() - 15 ) );
      query.setMaxResults( 10 );
      query.list();
      tx.commit();
      s.close();

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

      query = getQuery( "green",  parser, s );
      random.nextInt( query.getResultSize() - 15 );
      query.setFirstResult( random.nextInt( query.getResultSize() - 15 ) );
      query.setMaxResults( 10 );
      query.list();
      tx.commit();
      s.close();
    }

    private FullTextQuery getQuery(String queryString, QueryParser parser, Session s) {
View Full Code Here

    assertEquals( "Exection of getResultSize without actual results", 2, hibQuery.getResultSize() );
    assertEquals( "No entity should be loaded", 0, stats.getEntityLoadCount() );

    query = parser.parse( "summary:Festina Or brand:Seiko" );
    hibQuery = s.createFullTextQuery( query );
    List result = hibQuery.list();
    assertNotNull( result );
    assertEquals( "2 entities should be loaded", 2, stats.getEntityLoadCount() );
    if ( !enabled ) stats.setStatisticsEnabled( false );
    for (Object element : s.createQuery( "from java.lang.Object" ).list()) s.delete( element );
    tx.commit();
View Full Code Here

    Transaction tx = s.beginTransaction();
    QueryParser parser = new QueryParser("title", new StopAnalyzer() );

    Query query = parser.parse( "summary:lucene" );
    FullTextQuery hibQuery = s.createFullTextQuery( query, Book.class );
    List<Book> result = hibQuery.list();
    assertNotNull( result );
    assertEquals( "Wrong number of test results.", 3, result.size() );
    // make sure that the order is according to in which order the books got inserted
    // into the index.
    int id = 1;
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.