Uploaded image for project: 'Solr'
  1. Solr
  2. SOLR-2681

Lucene highlighting unable to extract terms from sub-query of a FunctionQuery

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 3.3
    • None
    • highlighter
    • None

    Description

      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"));
          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'");
        }
      

      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	
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            elecnix Nicolas Marchildon
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated: