Uploaded image for project: 'Lucene - Core'
  1. Lucene - Core
  2. LUCENE-1213

MultiFieldQueryParser ignores slop parameter

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: core/queryparser
    • Labels:
      None
    • Lucene Fields:
      Patch Available

      Description

      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.

      1. multifield-fix.patch
        2 kB
        Doron Cohen
      2. multifield-fix.patch
        1 kB
        Trejkaz

        Activity

        Hide
        trejkaz Trejkaz added a comment -

        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.

        Show
        trejkaz Trejkaz added a comment - 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.
        Hide
        doronc Doron Cohen added a comment - - 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.

        Show
        doronc Doron Cohen added a comment - - 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.
        Hide
        doronc Doron Cohen added a comment -

        Committed, thanks Trejkaz!

        Show
        doronc Doron Cohen added a comment - Committed, thanks Trejkaz!

          People

          • Assignee:
            doronc Doron Cohen
            Reporter:
            trejkaz Trejkaz
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development