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

Key: CMP-203
Type: New Feature New Feature
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Shay Banon
Reporter: Joe Zulli
Votes: 1
Watchers: 2
Operations

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

Add ability to filter queries by class

Created: 24/May/06 07:07 PM   Updated: 23/Feb/08 08:04 AM
Component/s: Compass::Core
Affects Version/s: 0.9.0
Fix Version/s: 1.2 M2

Environment: Java 5.0, OS X, Lucene 1.9.1


 Description  « Hide
I think it would be extrordinarily useful to have the ability to easily filter a search result based on class or type. For instance, I would like to create the following method in my API:

public <T> List search(Class<T> type, String queryString);

Inside the method I would do something like this (note not actual code):

CompassQuery query = session.queryBuilder().queryString(queryString).toQuery();
query.setType(type);

CompassHits hits = query.hits();
CompassDetachedHits detachedHits = hits.detach(0, getMaxSearchResults());
.....

..and so on. Currently there is no easy way to do this. You can get a handle to an InternalCompass, then a handle to the CompassMapping, and from there you can reverse engineer the alias name from the class name, but this is really tricky and requires a lot of code. I wasn't able to get it to totally work, I think it was something to do with my Spring setup.

I think this is a powerful approach, especially if you are using Compass Annotations, because both your data and metadata are essentially in the class. For me, it allows users of my API to perform a search withou having to have any compass specific knowledge at all.



 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Shay Banon added a comment - 14/Jun/07 05:00 PM
Added setTypes(Class[] types) to CompassQuery. Internally they get translated to setAliases().

Maurice Nicholson added a comment - 23/Feb/08 07:56 AM
Would it also be possible to add this feature to TermFreqsBuilder?

Possibly back ported to 1.2.x


Shay Banon added a comment - 23/Feb/08 08:04 AM
Sure, open a new issue for this feature.