SourceForge.net Logo
Main Overview Wiki Issues Forum Build Fisheye
Issue Details (XML | Word | Printable)

Key: CMP-816
Type: Improvement Improvement
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Shay Banon
Reporter: Kenny MacLeod
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Compass

Allow construction of CompassQueryBuilder without needing a CompassSession

Created: 22/Jan/09 10:41 AM   Updated: 26/Jan/09 05:12 PM
Component/s: Compass::Core
Affects Version/s: 2.1.1
Fix Version/s: 2.2.0 M2


 Description  « Hide
In some cases it is awkward to require access to a CompassSession before you can obtain a CompassQueryBuilder. It would be great if a CompassQuery could be programmatically constructed without referencing the session. Is this possible?

This is similar to the DetachedQuery introduced in Hibernate3, where previously you could only create a query from an existing HibernateSession.



 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Shay Banon added a comment - 26/Jan/09 11:17 AM
Hi Kenny, can you show a code example of how the Hibernate detached query works? Also, can you post how you envision the API to look like?

Kenny MacLeod added a comment - 26/Jan/09 11:28 AM
Here's the relevent part of the Hibernate manual:

http://www.hibernate.org/hib_docs/v3/reference/en-US/html/querycriteria-detachedqueries.html

The general point is that in Lucene, you can create a Query object without requiring a reference to the lucene runtime "entity", so from a lucene perspective there should be no reason why the compass API needs a CompassSession before creating a query.

At the moment, it's easier for my application to construct Lucene-native queries, and then pass them to compass which converts them into CompassQuery before running them. It's not nice, but it's preferable in this case to the application code getting hold of a compass session in order to build the query.


Shay Banon added a comment - 26/Jan/09 05:12 PM
ok, after (some) refactoring, I think I came up with a nice solution that is basically also backward compatible and without adding more APIs to the CompassSession interface (it would have become really crowded).

Basically, you can now using Compass#queryBuilder and Compass#queryFilterBuilder (the same API, which you still have, on CompassSession).

Then, once a CompassQuery created by using the Compass instance need to be used, it simply needs to be attached to a CompassSession using CompassQuery#attach(CompassSession). Note, this solution is completely thread safe, and the CompassQuery can be used in a multi threaded env.