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

Highlighting QueryVisitor & SpanQueryConverter



    • Type: Improvement
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: modules/highlighter
    • Labels:
    • Lucene Fields:


      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 Alan Woodward Jim Ferenczi




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


              • Created: