Package org.hibernate.search.jpa

Examples of org.hibernate.search.jpa.FullTextEntityManager.createFullTextQuery()


    );

    org.apache.lucene.search.Query luceneQuery;
    luceneQuery = parser.parse( searchQuery );

    final FullTextQuery query = ftEm.createFullTextQuery( luceneQuery, Book.class );

    return query;
  }
}
View Full Code Here


    FullTextEntityManager fullTextEm = Search.getFullTextEntityManager( em );
    Query luceneQuery = fullTextEm.getSearchFactory().buildQueryBuilder()
        .forEntity( RegisteredMember.class ).get()
        .keyword().onField( "name" ).matching( name ).createQuery();

    return fullTextEm.createFullTextQuery( luceneQuery ).getResultList();
  }

  @PostConstruct
  public void resetNewMember() {
    newMember = new RegisteredMember();
View Full Code Here

  public List<?> searchAllContacts() {
    FullTextEntityManager fullTextEntityManager = Search
        .getFullTextEntityManager( entityManager );

    FullTextQuery query = fullTextEntityManager.createFullTextQuery(
        new MatchAllDocsQuery(),
        Singer.class
    );

    return query.getResultList();
View Full Code Here

    em.getTransaction().commit();
    em.clear();
    em.getTransaction().begin();
    QueryParser parser = new QueryParser( "title", new StopAnalyzer() );
    Query query = parser.parse( "saltQty:noword" );
    assertEquals( 0, em.createFullTextQuery( query ).getResultList().size() );
    query = new TermQuery( new Term("saltQty", "23.0") );
    assertEquals( "getResultList", 1, em.createFullTextQuery( query ).getResultList().size() );
    assertEquals( "getSingleResult and object retrieval", 23f,
        ( (Bretzelem.createFullTextQuery( query ).getSingleResult() ).getSaltQty() );
    assertEquals( 1, em.createFullTextQuery( query ).getResultSize() );
View Full Code Here

    em.getTransaction().begin();
    QueryParser parser = new QueryParser( "title", new StopAnalyzer() );
    Query query = parser.parse( "saltQty:noword" );
    assertEquals( 0, em.createFullTextQuery( query ).getResultList().size() );
    query = new TermQuery( new Term("saltQty", "23.0") );
    assertEquals( "getResultList", 1, em.createFullTextQuery( query ).getResultList().size() );
    assertEquals( "getSingleResult and object retrieval", 23f,
        ( (Bretzelem.createFullTextQuery( query ).getSingleResult() ).getSaltQty() );
    assertEquals( 1, em.createFullTextQuery( query ).getResultSize() );
    em.getTransaction().commit();
View Full Code Here

    Query query = parser.parse( "saltQty:noword" );
    assertEquals( 0, em.createFullTextQuery( query ).getResultList().size() );
    query = new TermQuery( new Term("saltQty", "23.0") );
    assertEquals( "getResultList", 1, em.createFullTextQuery( query ).getResultList().size() );
    assertEquals( "getSingleResult and object retrieval", 23f,
        ( (Bretzelem.createFullTextQuery( query ).getSingleResult() ).getSaltQty() );
    assertEquals( 1, em.createFullTextQuery( query ).getResultSize() );
    em.getTransaction().commit();

    em.clear();
View Full Code Here

    assertEquals( 0, em.createFullTextQuery( query ).getResultList().size() );
    query = new TermQuery( new Term("saltQty", "23.0") );
    assertEquals( "getResultList", 1, em.createFullTextQuery( query ).getResultList().size() );
    assertEquals( "getSingleResult and object retrieval", 23f,
        ( (Bretzelem.createFullTextQuery( query ).getSingleResult() ).getSaltQty() );
    assertEquals( 1, em.createFullTextQuery( query ).getResultSize() );
    em.getTransaction().commit();

    em.clear();

    em.getTransaction().begin();
View Full Code Here

        BooleanJunction<BooleanJunction> bool = qb.bool();
        for (String searchTerm : searchTerms) {
            bool.must(context.matching(String.format("*%s*", searchTerm.toLowerCase())).createQuery());
        }

        final FullTextQuery fullTextQuery = session.createFullTextQuery(bool.createQuery(), clazz);
        fullTextQuery.setCriteriaQuery(query);
        return fullTextQuery;
    }

    @Override
View Full Code Here

                    // create native Lucene query
                    org.apache.lucene.queryParser.QueryParser parser = new QueryParser(ver, "modules.beanBytes", analyzer);           
                    parser.setAutoGeneratePhraseQueries(true)// http://lucene.jugem.jp/?eid=403
                    org.apache.lucene.search.Query luceneQuery = parser.parse(searchText);
                    // wrap Lucene query in a javax.persistence.Query
                    javax.persistence.Query persistenceQuery = fullTextEntityManager.createFullTextQuery(luceneQuery, DocumentModel.class);
           
                    // Too many results (>32768) cause
                    // java.io.IOException: Tried to send an out-of-range integer as a 2-byte value: xxxxx
                    // 暫定的に 1000 にしておく
                    persistenceQuery.setMaxResults(1000);
View Full Code Here

                boostPerField);

        org.apache.lucene.search.Query luceneQuery;
        luceneQuery = parser.parse(searchQuery);

        final FullTextQuery query = ftEm.createFullTextQuery(luceneQuery, Book.class);

        return query;
    }

}
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.