Package org.hibernate.search

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


    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


    FullTextSession s = Search.createFullTextSession( sess );
    tx = s.beginTransaction();
    QueryParser parser = new QueryParser( "title", new KeywordAnalyzer() );
    Query query = parser.parse( "name:moo" );
    FullTextQuery hibQuery = s.createFullTextQuery( query, Author.class, Music.class );
    List result = hibQuery.list();
    assertEquals( "Should have returned no author", 0, result.size() );

    for (Object o : s.createCriteria( Object.class ).list()) {
      s.delete( o );
    }
View Full Code Here

            Criteria criteria = getFullTextSession().createCriteria(Topic.class).add(
                    Restrictions.in("branch.id", allowedBranchesIds)
            );
            query.setCriteriaQuery(criteria);

            topics = query.list();
            resultSize = query.getResultSize();
        }

        return new PageImpl<Topic>(topics, pageRequest, resultSize);
    }
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

      // Search
      FullTextSession ftSession = Search.getFullTextSession( sf.openSession(  ) );
      final FullTextQuery textQuery = ftSession.createFullTextQuery( q, Boat.class )
          .setMaxResults( 100 ).setProjection( "name" );
      long start = System.currentTimeMillis();
      List results = textQuery.list();
      int resultSize = textQuery.getResultSize();
      long totalTime = System.currentTimeMillis() - start;
      ftSession.close();
//      log.error( "HSearch [ Thread-id : " + threadId + " ] Total time taken for search is : " + totalTime + "ms with total no. of matching records : " + resultSize );
      setTime( totalTime );
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

    // now the same query, but with a lucene sort specified.
    query = parser.parse( "summary:lucene" );
    hibQuery = s.createFullTextQuery( query, Book.class );
    Sort sort = new Sort(new SortField("id", true));
    hibQuery.setSort(sort);
    result = hibQuery.list();
    assertNotNull( result );
    assertEquals( "Wrong number of test results.", 3, result.size() );
    id = 3;
    for(Book b : result) {
      assertEquals("Expected another id", Integer.valueOf( id ), b.getId());
View Full Code Here

    // order by summary
    query = parser.parse( "summary:lucene OR summary:action" );
    hibQuery = s.createFullTextQuery( query, Book.class );
    sort = new Sort( new SortField( "summary_forSort", false ) ); //ASC
    hibQuery.setSort( sort );
    result = hibQuery.list();
    assertNotNull( result );
    assertEquals( "Wrong number of test results.", 4, result.size() );
    assertEquals( "Groovy in Action", result.get( 0 ).getSummary() );

    // order by summary backwards
View Full Code Here

    // order by summary backwards
    query = parser.parse( "summary:lucene OR summary:action" );
    hibQuery = s.createFullTextQuery( query, Book.class );
    sort = new Sort( new SortField( "summary_forSort", true ) ); //DESC
    hibQuery.setSort( sort );
    result = hibQuery.list();
    assertNotNull( result );
    assertEquals( "Wrong number of test results.", 4, result.size() );
    assertEquals( "Hibernate & Lucene", result.get( 0 ).getSummary() );

    // order by date backwards
View Full Code Here

    // order by date backwards
    query = parser.parse( "summary:lucene OR summary:action" );
    hibQuery = s.createFullTextQuery( query, Book.class );
    sort = new Sort( new SortField( "publicationDate", SortField.STRING, true ) ); //DESC
    hibQuery.setSort( sort );
    result = hibQuery.list();
    assertNotNull( result );
    assertEquals( "Wrong number of test results.", 4, result.size() );
    for (Book book : result) {
      System.out.println(book.getSummary() + " : " + book.getPublicationDate() );
    }
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.