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

Nested SpanNear queries lose positional highlights

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Duplicate
    • Affects Version/s: 4.3.1, 4.6.1
    • Fix Version/s: 7.3
    • Component/s: modules/highlighter
    • Labels:
      None
    • Lucene Fields:
      New

      Description

      Given text of: "x y z x z x a"
      With a query of: spanNear([spanNear([text:x, text:y, text:z], 0, true), text:a], 10, false)
      Resulting highlight: <B>x</B> <B>y</B> <B>z</B> <B>x</B> <B>z</B> <B>x</B> <B>a</B>
      Expected highlight: <B>x</B> <B>y</B> <B>z</B> x z x <B>a</B>

      This is caused because WeightedSpanTermExtractor.extractWeightedSpanTerms takes the SpanQuery and flattens all terms and uses the positions from the outermost SpanNear clause (ignoring the nested SpanNear positions). I believe this could be resolved with a little recursion - walking the span query tree in the extractWeightedSpanTerms method.

        Attachments

        1. LUCENE-5455-Tests.patch
          5 kB
          Steve Davids

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                sdavids Steve Davids
              • Votes:
                1 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: