Examples of createFullTextQuery()


Examples of org.hibernate.search.FullTextSession.createFullTextQuery()

    return ftSession;
  }

  public FullTextQuery createFullTextQuery(org.apache.lucene.search.Query luceneQuery, Class<?>... entities) {
    FullTextSession ftSession = getFullTextSession();
    return new FullTextQueryImpl( ftSession.createFullTextQuery( luceneQuery, entities ), ftSession );
  }

  public <T> void index(T entity) {
    getFullTextSession().index( entity );
  }
View Full Code Here

Examples of org.hibernate.search.FullTextSession.createFullTextQuery()

    LuceneQueryParsingResult parsingResult = new QueryParser().parseQuery( queryString,
        createProcessingChain( session, unwrap( namedParameters ), fullTextSession ) );

    log.createdQuery( queryString, parsingResult.getQuery() );

    FullTextQuery fullTextQuery = fullTextSession.createFullTextQuery( parsingResult.getQuery(), parsingResult.getTargetEntity() );
    if ( requiresProjections( parsingResult.getProjections() ) ) {
      fullTextQuery.setProjection( parsingResult.getProjections().toArray( new String[parsingResult.getProjections().size()] ) );
    }

    fullTextQuery.setSort( parsingResult.getSort() );
View Full Code Here

Examples of org.hibernate.search.FullTextSession.createFullTextQuery()

    tx.commit();

    tx = s.beginTransaction();
    QueryParser parser = new QueryParser( "name", new StandardAnalyzer() );
    Query query = parser.parse( "name:foo" );
    FullTextQuery hibQuery = s.createFullTextQuery( query );
    try {
      hibQuery.list();
      fail();
    }
    catch ( HibernateException e ) {
View Full Code Here

Examples of org.hibernate.search.FullTextSession.createFullTextQuery()

    createTestBooks(s);
    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.
View Full Code Here

Examples of org.hibernate.search.FullTextSession.createFullTextQuery()

      id++;
    }

    // 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() );
View Full Code Here

Examples of org.hibernate.search.FullTextSession.createFullTextQuery()

      id--;
    }

    // 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() );
View Full Code Here

Examples of org.hibernate.search.FullTextSession.createFullTextQuery()

    assertEquals( "Wrong number of test results.", 4, result.size() );
    assertEquals( "Groovy in Action", result.get( 0 ).getSummary() );

    // 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() );
View Full Code Here

Examples of org.hibernate.search.FullTextSession.createFullTextQuery()

    assertEquals( "Wrong number of test results.", 4, result.size() );
    assertEquals( "Hibernate & Lucene", result.get( 0 ).getSummary() );

    // 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() );
View Full Code Here

Examples of org.hibernate.search.FullTextSession.createFullTextQuery()

    Map<String, Float> boosts = new HashMap<String, Float>(2);
    boosts.put( "title", new Float(4) );
    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() );
View Full Code Here

Examples of org.hibernate.search.FullTextSession.createFullTextQuery()

    Query query = parser.parse( "combi OR sport" );

    Criteria criteria = session.createCriteria( AbstractCar.class );
    criteria.add( Restrictions.eq( "hasColor", Boolean.FALSE ) );

    org.hibernate.Query hibQuery = fullTextSession.createFullTextQuery( query, AbstractCar.class )
        .setCriteriaQuery( criteria );
    List result = hibQuery.list();
    assertEquals( 2, result.size() );
    tx.commit();
    session.close();
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.