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

Highlighting QueryVisitor & SpanQueryConverter

Details

    • Improvement
    • Status: Open
    • Major
    • Resolution: Unresolved
    • None
    • None
    • modules/highlighter
    • None
    • New

    Description

      Frustratingly we still don't have a Query visitor API in Lucene ( LUCENE-3041 ) so I took a basic stab at it within the confines of the UnifiedHighlighter. This patch is more of a simple pragmatic solution for the UH than it is for the wholistic goals of LUCENE-3041 (that would likely change Query itself). Today the UH has one massive if-else Query branch – MultiTermHighlighting, plus it re-uses WeightedSpanTermExtractor (WSTE) from the original Highlighter in a rather hacky way. In this patch I introduce QueryVisitor.java to the UH that has the massive instanceof branches in it with many places to subclass. I modified MultiTermHighlighting to use it and I modified PhraseHelper as well to wean itself off of WSTE. Interestingly PhraseHelper needed to instantiate this a second time since it needed to separately look to see if the SpanQuery contained a SpanMultiTermQueryWrapper. QueryVisitor and some usage sites contain numerous TODOs to elicit some conversation in a code review about the approach.

      To fully wean the UH off of WSTE, I also added a SpanQueryConverter for converting PhraseQuery and MultiPhraseQuery. Again I also conservatively added it to the highlighter module even though it's of a general nature.

      Although the patch "works", it needs cleanup and feedback.

      CC romseygeek jimczi

      Attachments

        Activity

          People

            dsmiley David Smiley
            dsmiley David Smiley
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: