How to prevent solr from highlighting unmatched te

2019-07-22 09:10发布

问题:

I have a complex query with several terms "OR"d together. I am getting the correct documents returned, but the highlights include the terms which did not match. For example, a query like this:

text: (cat OR (dog AND ohio))

will match documents containing "cat" but not "ohio". The problems is that it will highlight "dog" in that document even though "dog" only appears in the "dog AND ohio" clause, which does not match the current document.

Is there some way to restrict the highlighter to only highlight terms from successfully matched clauses?