Hi,

We have implemented a custom query that extends MultiPhraseQuery (MPQ) because 
it uses MPQ's getTermArrays() and getPositions(). We'd like to use this query 
for highlighting, but we're facing the following issue.

In highlighter/WeightedSpanTermExtractor, the extract() method does a series of 
instanceof checks. There is a special case for MPQ. This branch does not call 
rewrite(IndexReader) on the query, but our custom query needs rewriting to work 
properly.

As a test, I commented the MPQ branch in WeightedSpanTermExtractor so the code 
takes the last else branch, where rewrite(IndexReader) is called, and our tests 
pass.

My questions are

  *   Are we doing it wrong when our query *needs* rewriting? Our query logic 
needs the IndexReader that's passed in in rewrite(IndexReader). Where else 
would we put such code?
  *   If we aren't doing it wrong, how can we use the highlighter? Extend Query 
instead of MPQ and copy the tracking of term arrays and positions from MPQ?

Thanks,
Thomas

Reply via email to