You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@solr.apache.org by "ASF GitHub Bot (Jira)" <ji...@apache.org> on 2026/10/11 00:16:00 UTC

[jira] [Updated] (SOLR-2681) Lucene highlighting unable to extract terms from sub-query of a FunctionQuery

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

ASF GitHub Bot updated SOLR-2681:
---------------------------------
    Labels: pull-request-available  (was: )

> Lucene highlighting unable to extract terms from sub-query of a FunctionQuery
> -----------------------------------------------------------------------------
>
>                 Key: SOLR-2681
>                 URL: https://issues.apache.org/jira/browse/SOLR-2681
>             Project: Solr
>          Issue Type: Bug
>          Components: highlighter
>    Affects Versions: 3.3
>            Reporter: Nicolas Marchildon
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> When using a function query with an argument being a term query, I would expect the highlighter to be able to extract the term.
> Lucene's WeightedSpanTermExtractor used by QueryScorer does not know about FunctionQuery, so it is not able to recurse into it for extracting terms.
> Here's a HighlighterTest that I believe reproduces the behavior I'm seeing:
> {code}
>   public void testHighlightFunction() {
>     assertU(adoc("t_text", "lorem ipsum", "id", "1"));
>     assertU(commit());
>     assertQ("function highlighting", 
>             req("q", "{!func}product($v1,$v2)", "v1", "{!dismax qf=t_text}lorem", "v2", "100.0", "hl", "true", "hl.fl", "t_text"),
>             "//lst[@name='highlighting']/lst[@name='1']" +
>             "/arr[@name='t_text']/str='<em>lorem</em> ipsum'");
>   }
> {code}
> The WeightedSpanTermExtractor does many {{instanceof}}, in which Solr's FunctionQuery is unknown. Solr should provide a QueryScorer that knows how to extract terms from a QueryValueSource inside a FunctionQuery.
> Here's the stack that leads to the term extraction:
> {code}
> Thread [main] (Suspended (breakpoint at line 106 in WeightedSpanTermExtractor))	
> 	WeightedSpanTermExtractor.extract(Query, Map) line: 106	
> 	WeightedSpanTermExtractor.getWeightedSpanTerms(Query, TokenStream, String) line: 414	
> 	QueryScorer.initExtractor(TokenStream) line: 216	
> 	QueryScorer.init(TokenStream) line: 184	
> 	Highlighter.getBestTextFragments(TokenStream, String, boolean, int) line: 226	
> 	Highlighter.getBestFragments(TokenStream, String, int) line: 184	
> 	Highlighter.getBestFragment(TokenStream, String) line: 107	
> 	Highlighter.getBestFragment(Analyzer, String, String) line: 85	
> {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org