Package org.hibernate.search

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


    // 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", new Integer(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

    FullTextSession s = Search.createFullTextSession( sess );
    tx = s.beginTransaction();
    QueryParser parser = new QueryParser( "title", new KeywordAnalyzer() );
    Query query = parser.parse( "title:moo" );
    FullTextQuery hibQuery = s.createFullTextQuery( query, Music.class );
    List result = hibQuery.list();
    assertEquals( "Should have returned 2 Books", 2, result.size() );
    music = (Music) result.get( 0 );
    assertEquals( "Book 1 should have four authors", 4, music.getAuthors().size() );
    music2 = (Music) result.get( 1 );
    assertEquals( "Book 2 should have four authors", 4, music2.getAuthors().size() );
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

    tx = s.beginTransaction();
    String searchQuery = "Joe";
    QueryParser parser = new QueryParser( "Content", new 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

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.