Uploaded image for project: 'Lucene - Core'
  1. Lucene - Core
  2. LUCENE-7769

UnifiedHighlighter doesn't highlight MTQs wrapped in BoostQuery

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 6.4.2, 6.5
    • 6.5.1, 7.0
    • modules/highlighter
    • None
    • New

    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:

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

      My opinion it's because MultiTermHighlighting.extractAutomata() returns an empty automaton for BoostQuery. I think, should add some thing like:

      if (query instanceof BoostQuery) 
      {
            list.addAll(Arrays.asList(extractAutomata(((BoostQuery) query).getQuery(), fieldMatcher, lookInSpan, preRewriteFunc))) ; 
      } 
      

      to MultiTermHighlighting.extractAutomata()
      Thanks.

      Attachments

        Activity

          People

            dsmiley David Smiley
            dmitrymalinin Dmitry Malinin
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: