Package org.hibernate.search

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


    boosts.put( "description", new Float(1) );
    MultiFieldQueryParser parser = new MultiFieldQueryParser(new String[] {"title", "description"}, new StandardAnalyzer(), boosts);
    Query luceneQuery = parser.parse( "dark" );
    FullTextQuery ftQuery = s.createFullTextQuery( luceneQuery, Dvd.class )
        .setProjection( FullTextQuery.DOCUMENT_ID, FullTextQuery.EXPLANATION, FullTextQuery.THIS );
    @SuppressWarnings("unchecked") List<Object[]> results = ftQuery.list();
    assertEquals( 2, results.size() );
    for (Object[] result : results) {
      assertEquals( ftQuery.explain( (Integer) result[0] ).toString(), result[1].toString() );
      s.delete( result[2] );
    }
View Full Code Here


    FullTextSession s = Search.getFullTextSession( 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

      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

    FullTextSession s = Search.getFullTextSession( 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

  public int countBusLinesByFullText() {
    FullTextSession fullTextSession = Search.getFullTextSession( sessions.openSession() );
    Transaction tx = fullTextSession.beginTransaction();
    org.apache.lucene.search.Query ftQuery = new MatchAllDocsQuery();
    FullTextQuery query = fullTextSession.createFullTextQuery( ftQuery, BusLine.class );
    int count = query.list().size();
    tx.commit();
    fullTextSession.close();
    return count;
  }
 
View Full Code Here

  public int countBusLinesByFullText() {
    FullTextSession fullTextSession = Search.getFullTextSession( openSession() );
    Transaction tx = fullTextSession.beginTransaction();
    org.apache.lucene.search.Query ftQuery = new MatchAllDocsQuery();
    FullTextQuery query = fullTextSession.createFullTextQuery( ftQuery, BusLine.class );
    int count = query.list().size();
    tx.commit();
    fullTextSession.close();
    return count;
  }
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.