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

Key: CMP-399
Type: Improvement Improvement
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Shay Banon
Reporter: Maurice Nicholson
Votes: 0
Watchers: 0
Operations

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

CompassQueryBuilder#spanFirst needs to be overloaded with variant that takes CompassSpanQuery, allowing to use Lucene "starts with" query best practice

Created: 13/May/07 08:11 AM   Updated: 18/May/07 01:42 AM
Component/s: Compass::Core
Affects Version/s: 1.1 GA
Fix Version/s: 1.2 M2


 Description  « Hide
Luene's own SpanFirstQuey takes another SpanQuery instance as one of it's two constructor arguments.

This allows what I think is the Lucene best practice for a "starts with" query such (pseudo code, not tested):

term1 = new SpanTermQuery(new Term("title", "ready"))
term2 = new SpanTermQuery(new Term("title", "steady"))
term3 = new SpanTermQuery(new Term("title", "go"))
near = new SpanNearQuery({term1, term2, term3}, 1, true)
startsWith = new SpanFirstQuery(near, 1)

But this isn't possible with CompassQueryBuilder#startsWith, since that method only takes an object term value, rather than another CompassSpanQuery. It would be possible if CompassQueryBuilder#startsWith had an overloaded version taking a CompassSpanQuery built with CompassQueryBuilder#spanNear.

Also a "starts with" query builder would be a nice feature to support in a simplified format, eg, CompassQueryBuilder could have a method returning CompassStartsWithQueryBuilder with an "add" method to add terms. However, this technique only works for whole terms - it's NOT a prefix query - so the name you choose and documentation would have to make that clear.



 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Shay Banon added a comment - 14/May/07 12:39 PM
There is an option to do it with CompassQueryBuilder since CompassQuerySpanNearBuilder has a method called: CompassQuerySpanNearBuilder add(CompassSpanQuery query);. In such cases, the resource property name is irrelevant and discarded. Not the nicest way (my bad), but it should work.

Maurice Nicholson added a comment - 15/May/07 03:28 AM
Yes but this only gets you so far: span near queries match when the terms are near each other, but say nothing about the terms' relative position in the field: that is why a span first query is also needed.

If you look at the code block in the initial description, using CompassQueryBuilder#spanNear would give you an equivalent to the "near" query object in the penultimate line, but you still need a span first which ties it to the start of the field!

Actually I just re-read my initial description and there is a mistake: underneath the code block I mention "CompassQueryBuilder#startsWith" when I actually mean "CompassQueryBuilder#spanFirst".


Shay Banon added a comment - 18/May/07 01:42 AM
Makes perfect sense and an oversight on my part.