Hide Forgot
Title: Querying Describe the issue: Example 5.1. Creating a FullTextSession Session session = sessionFactory.openSession(); ... FullTextSession fullTextSession = Search.getFullTextSession(session); And following code snippet Suggestions for improvement: Should be changed to Example 5.1. Get SearchManager out of an indexing enabled cache SearchManager manager = Search.getSearchManager(cache); Create hibernate search QueryBuilder to build queries for Myth.class final org.hibernate.search.query.dsl.QueryBuilder queryBuilder = manager.buildQueryBuilderForClass(Myth.class).get(); Create apache lucene query for querying atributes of Myth.class org.apache.lucene.search.Query query = queryBuilder.keyword() .onField("history").boostedTo(3) .matching("storm") .createQuery(); // wrap Lucene query in a org.infinispan.query.CacheQuery CacheQuery cacheQuery = Search.getSearchManager(cache).getQuery(query); // Get query result List<Myth> result = cacheQuery.list(); Additional information: NeedInfo from anistor or sanne for approval maybe I am not correct somewhere
And I made mistake here // wrap Lucene query in a org.infinispan.query.CacheQuery CacheQuery cacheQuery = Search.getSearchManager(cache).getQuery(query); should be // wrap Lucene query in a org.infinispan.query.CacheQuery CacheQuery cacheQuery = manager.getQuery(query);
Hi Adrian, can you confirm the above?
Hi Misha, Vitalii's observations are correct, but I noticed the section has several other problems besides this code snippet. I'll add another BZ for the 'other' problems. Meanwhile, I would also add to what Vitalii said: 1. Nitpicking: I would prefer Example 5.1 to be titled "Getting the SearchManager of an indexing enabled cache" 2. Please mark the Java comments with //. Also use proper capitalisation, "hibernate search" -> "Hibernate Search", "apache lucene" -> "Apache Lucene" 3. The last two lines of the code snippet should be chnaged to: // Get query result List<Object> result = cacheQuery.list(); This is needed because CacheQuery.list() method is not generic.
Oh sorry, I was confused by the title. I see it now. The sample code in Querying section is fine now. But as I said before, theare are other problems in this section, so lets fix those too without opening a new BZ. Namely, the text at the begining of the section is wrong: "Infinispan Query can execute Lucene queries and retrieve domain objects managed by an Infinispan session. The search provides the power of Lucene without leaving the Hibernate paradigm, giving another dimension to the Hibernate classic search mechanisms (HQL, Criteria query, native SQL query)." No such thing as Infnispan session and the comparison with Hibernate paradigm is not needed. So let's replace this with: "Infinispan Query can execute Lucene queries and retrieve domain objects from an Infinispan cache."
Well, actually we cannot say "an Infinispan cache" :) Let's say "a RH JBoss Data Grid cache" :)
It's fine now. Can be closed.
The fix for this bug is now generally released and available here: https://access.redhat.com/site/documentation/en-US/Red_Hat_JBoss_Data_Grid/6.2/index.html