[ 
https://issues.apache.org/jira/browse/LUCENE-4728?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13568715#comment-13568715
 ] 

Uwe Schindler commented on LUCENE-4728:
---------------------------------------

Hi,
I had the same problem while implementing a custom query for a customer. The 
query was very easy, it just rewrote after expanding terms to MultiPhraseQuery 
- you would expect that this works with highlighter! - But it doen't. The 
problem is that highligther does not even try to rewrite the query, it only 
checks via instanceof checks the *original* query type, failing to highlight my 
simple query without custom weights and scorers, just a very simple rewrite 
method. That is not a good design! If the highlighter would rewrite the query 
as a last chance this problem would have been solved. The problem with that is 
a second one in the crazy Lucene Highlighter: You need the field name for 
highlighter to work :(

For this customer my only chance was to use Javassist to hot-patch the 
WeightedSpanTermExtractor and add another instanceof check. Overriding the 
fallback to handle other queries was impossible because the customer's 
framework was ElasticSearch which has a highly private, unextendable 
WeightedSpanTermExtractor with no possibility to override the Lucene default :( 
[same applies for Solr]

This brings us back to a very old issue: We should extend the Query class by a 
simple additional API, so it can provide all metadata needed to do highlighting 
without crazy instaceof chains.
                
> Allow CommonTermsQuery to be highlighted
> ----------------------------------------
>
>                 Key: LUCENE-4728
>                 URL: https://issues.apache.org/jira/browse/LUCENE-4728
>             Project: Lucene - Core
>          Issue Type: Improvement
>          Components: modules/highlighter
>    Affects Versions: 4.1
>            Reporter: Simon Willnauer
>            Assignee: Simon Willnauer
>             Fix For: 4.2, 5.0
>
>         Attachments: LUCENE-4728.patch, LUCENE-4728.patch
>
>
> Add support for CommonTermsQuery to all highlighter impls. 
> This might add a dependency (query-jar) to the highlighter so we might think 
> about adding it to core?

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to