Bug 1035620 - FullTextSession fullTextSession = Search.getFullTextSession(session) is related to hibernate but not to infinispan querying
Summary: FullTextSession fullTextSession = Search.getFullTextSession(session) is relat...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: JBoss Data Grid 6
Classification: JBoss
Component: Documentation
Version: 6.2.0
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: GA
: 6.2.0
Assignee: Misha H. Ali
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-11-28 08:34 UTC by Vitalii Chepeliuk
Modified: 2014-01-16 00:01 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Build Name: 14318, Infinispan Query Guide-6.2-1 Build Date: 28-11-2013 16:34:04 Topic ID: 14227-558221 [Latest]
Last Closed: 2014-01-16 00:01:55 UTC
Type: Bug


Attachments (Terms of Use)

Description Vitalii Chepeliuk 2013-11-28 08:34:46 UTC
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

Comment 1 Vitalii Chepeliuk 2013-11-28 08:38:20 UTC
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);

Comment 3 Misha H. Ali 2013-11-28 09:35:17 UTC
Hi Adrian, can you confirm the above?

Comment 4 Adrian Nistor 2013-11-28 21:12:26 UTC
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.

Comment 8 Adrian Nistor 2013-11-29 11:21:21 UTC
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."

Comment 9 Adrian Nistor 2013-11-29 11:29:21 UTC
Well, actually we cannot say "an Infinispan cache" :) Let's say "a RH JBoss Data Grid cache" :)

Comment 11 Adrian Nistor 2013-12-02 14:11:07 UTC
It's fine now. Can be closed.

Comment 12 Misha H. Ali 2014-01-16 00:01:55 UTC
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


Note You need to log in before you can comment on or make changes to this bug.