Grokbase Groups Lucene dev July 2011
Lucene highlighting unable to extract terms from sub-query of a FunctionQuery

Key: SOLR-2681
Project: Solr
Issue Type: Bug
Components: highlighter
Affects Versions: 3.3
Reporter: Nicolas Marchildon

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:

public void testHighlightFunction() {
assertU(adoc("t_text", "lorem ipsum", "id", "1"));
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'");

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:

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

This message is automatically generated by JIRA.
For more information on JIRA, see:

To unsubscribe, e-mail:
For additional commands, e-mail:

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupdev @
postedJul 28, '11 at 4:35p
activeJul 28, '11 at 4:35p

1 user in discussion

Nicolas Marchildon (JIRA): 1 post



site design / logo © 2021 Grokbase