Issue Details (XML | Word | Printable)

Key: LUCENE-1213
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Doron Cohen
Reporter: Trejkaz
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Lucene - Java

MultiFieldQueryParser ignores slop parameter

Created: 09/Mar/08 10:40 PM   Updated: 11/Mar/08 08:07 AM
Return to search
Component/s: QueryParser
Affects Version/s: None
Fix Version/s: None

Time Tracking:
Not Specified

File Attachments:
  Size
Text File Licensed for inclusion in ASF works multifield-fix.patch 2008-03-10 06:57 AM Doron Cohen 2 kB
Text File Licensed for inclusion in ASF works multifield-fix.patch 2008-03-09 11:33 PM Trejkaz 1 kB

Lucene Fields: Patch Available
Resolution Date: 11/Mar/08 08:07 AM


 Description  « Hide
MultiFieldQueryParser.getFieldQuery(String, String, int) calls super.getFieldQuery(String, String), thus obliterating any slop parameter present in the query.

It should probably be changed to call super.getFieldQuery(String, String, int), except doing only that will result in a recursive loop which is a side-effect of what may be a deeper problem in MultiFieldQueryParser – getFieldQuery(String, String, int) is documented as delegating to getFieldQuery(String, String), yet what it actually does is the exact opposite. This also causes problems for subclasses which need to override getFieldQuery(String, String) to provide different behaviour.



 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Trejkaz added a comment - 09/Mar/08 11:33 PM
Attaching one possible fix. It's more verbose than I wish it could be, but I couldn't think of a reliable way to make it delegate as it would require casting the result to BooleanQuery to get the clauses our, and a subclass may return something else entirely.

Doron Cohen added a comment - 10/Mar/08 06:57 AM - edited
Trejkaz thanks for the patch.

Attached a slightly compacted fix (refactoring slop-applying to a separate method).
Also added a test that fails without this fix.

All tests pass, if there are no comments I will commit this in a day or two.


Doron Cohen added a comment - 11/Mar/08 08:07 AM
Committed, thanks Trejkaz!