[ 
https://issues.apache.org/jira/browse/LUCENE-7769?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

David Smiley updated LUCENE-7769:
---------------------------------
    Description: 
UnifiedHighlighter doesn't highlight MTQ wrapped in BoostQuery.
For example, suppose we have a doc with a field 'f' contains data 'lucene'. 
UnifiedHighlighter highlights query _(f:lucene*)_, but query _(f:lucene*)^1_ 
doesn't. Test code:
{code}
String field = "f";
String content = "lucene";
Term term = new Term(field, content);
UnifiedHighlighter highlighter = new UnifiedHighlighter(null, new 
StandardAnalyzer());
Query[] queries = {new PrefixQuery(term), new BoostQuery(new PrefixQuery(term), 
1.0f)};
Object fragObj;         
for (Query query : queries)
{
        fragObj = highlighter.highlightWithoutSearcher(field, query, content, 
1);
        System.out.printf("content=[%s]  Query=%s  frag=[%s]\n", content, 
query, fragObj);
}
{code}
My opinion it's because MultiTermHighlighting.extractAutomata() returns an 
empty automaton for BoostQuery. I think, should add some thing like:
{code}
if (query instanceof BoostQuery) 
{
      list.addAll(Arrays.asList(extractAutomata(((BoostQuery) 
query).getQuery(), fieldMatcher, lookInSpan, preRewriteFunc))) ; 
} 
{code}
to MultiTermHighlighting.extractAutomata()
Thanks.


  was:
UnifiedHighlighter doesn't highlight MTQ wrapped in BootsQuery.
For example, suppose we have a doc with a field 'f' contains data 'lucene'. 
UnifiedHighlighter highlights query _(f:lucene*)_, but query _(f:lucene*)^1_ 
doesn't. Test code:
{code}
String field = "f";
String content = "lucene";
Term term = new Term(field, content);
UnifiedHighlighter highlighter = new UnifiedHighlighter(null, new 
StandardAnalyzer());
Query[] queries = {new PrefixQuery(term), new BoostQuery(new PrefixQuery(term), 
1.0f)};
Object fragObj;         
for (Query query : queries)
{
        fragObj = highlighter.highlightWithoutSearcher(field, query, content, 
1);
        System.out.printf("content=[%s]  Query=%s  frag=[%s]\n", content, 
query, fragObj);
}
{code}
My opinion it's because MultiTermHighlighting.extractAutomata() returns an 
empty automaton for BoostQuery. I think, should add some thing like:
{code}
if (query instanceof BoostQuery) 
{
      list.addAll(Arrays.asList(extractAutomata(((BoostQuery) 
query).getQuery(), fieldMatcher, lookInSpan, preRewriteFunc))) ; 
} 
{code}
to MultiTermHighlighting.extractAutomata()
Thanks.


        Summary: UnifiedHighlighter doesn't highlight MTQs wrapped in 
BoostQuery  (was: UnifiedHighlighter doesn't highlight PrefixQuery wrapped in 
BootsQuery)

> UnifiedHighlighter doesn't highlight MTQs wrapped in BoostQuery
> ---------------------------------------------------------------
>
>                 Key: LUCENE-7769
>                 URL: https://issues.apache.org/jira/browse/LUCENE-7769
>             Project: Lucene - Core
>          Issue Type: Bug
>          Components: modules/highlighter
>    Affects Versions: 6.5, 6.4.2
>            Reporter: Dmitry Malinin
>
> UnifiedHighlighter doesn't highlight MTQ wrapped in BoostQuery.
> For example, suppose we have a doc with a field 'f' contains data 'lucene'. 
> UnifiedHighlighter highlights query _(f:lucene*)_, but query _(f:lucene*)^1_ 
> doesn't. Test code:
> {code}
> String field = "f";
> String content = "lucene";
> Term term = new Term(field, content);
> UnifiedHighlighter highlighter = new UnifiedHighlighter(null, new 
> StandardAnalyzer());
> Query[] queries = {new PrefixQuery(term), new BoostQuery(new 
> PrefixQuery(term), 1.0f)};
> Object fragObj;               
> for (Query query : queries)
> {
>       fragObj = highlighter.highlightWithoutSearcher(field, query, content, 
> 1);
>       System.out.printf("content=[%s]  Query=%s  frag=[%s]\n", content, 
> query, fragObj);
> }
> {code}
> My opinion it's because MultiTermHighlighting.extractAutomata() returns an 
> empty automaton for BoostQuery. I think, should add some thing like:
> {code}
> if (query instanceof BoostQuery) 
> {
>       list.addAll(Arrays.asList(extractAutomata(((BoostQuery) 
> query).getQuery(), fieldMatcher, lookInSpan, preRewriteFunc))) ; 
> } 
> {code}
> to MultiTermHighlighting.extractAutomata()
> Thanks.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

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

Reply via email to