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

UnifiedHighlighter doesn't highlight MTQs wrapped in BoostQuery

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 6.5, 6.4.2
    • Fix Version/s: 7.0, 6.5.1
    • Component/s: modules/highlighter
    • Labels:
      None
    • Lucene Fields:
      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.

        Activity

        Hide
        dsmiley David Smiley added a comment -

        Quite right; thanks for reporting this Dmitry Malinin! This root cause is a larger issue of there being no Query traversal API in Lucene, which bites highlighters in the but all the time. LUCENE-3041

        I won't 'have time to fix this until another 6 hours from now... likely after the planned RC. Ping Joel Bernstein

        Show
        dsmiley David Smiley added a comment - Quite right; thanks for reporting this Dmitry Malinin ! This root cause is a larger issue of there being no Query traversal API in Lucene, which bites highlighters in the but all the time. LUCENE-3041 I won't 'have time to fix this until another 6 hours from now... likely after the planned RC. Ping Joel Bernstein
        Hide
        dsmiley David Smiley added a comment -

        Here's a patch. The problem here is also for SpanBoostQuery which I added a test for.

        Show
        dsmiley David Smiley added a comment - Here's a patch. The problem here is also for SpanBoostQuery which I added a test for.
        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit 0ca7a7a02853548e37eb93f2eb94a36aebb9ed0b in lucene-solr's branch refs/heads/master from David Smiley
        [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=0ca7a7a ]

        LUCENE-7769: UnifiedHighlighter wasn't seeing inside BoostQuery or SpanBoostQuery

        Show
        jira-bot ASF subversion and git services added a comment - Commit 0ca7a7a02853548e37eb93f2eb94a36aebb9ed0b in lucene-solr's branch refs/heads/master from David Smiley [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=0ca7a7a ] LUCENE-7769 : UnifiedHighlighter wasn't seeing inside BoostQuery or SpanBoostQuery
        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit 05b101f601c179c86985c4d9e26fa70354c4b196 in lucene-solr's branch refs/heads/branch_6x from David Smiley
        [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=05b101f ]

        LUCENE-7769: UnifiedHighlighter wasn't seeing inside BoostQuery or SpanBoostQuery

        (cherry picked from commit 0ca7a7a)

        Show
        jira-bot ASF subversion and git services added a comment - Commit 05b101f601c179c86985c4d9e26fa70354c4b196 in lucene-solr's branch refs/heads/branch_6x from David Smiley [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=05b101f ] LUCENE-7769 : UnifiedHighlighter wasn't seeing inside BoostQuery or SpanBoostQuery (cherry picked from commit 0ca7a7a)
        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit 3176e650b250af6eb08a3ff6b073c5b649b7e467 in lucene-solr's branch refs/heads/branch_6_5 from David Smiley
        [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=3176e65 ]

        LUCENE-7769: UnifiedHighlighter wasn't seeing inside BoostQuery or SpanBoostQuery

        (cherry picked from commit 05b101f)

        Show
        jira-bot ASF subversion and git services added a comment - Commit 3176e650b250af6eb08a3ff6b073c5b649b7e467 in lucene-solr's branch refs/heads/branch_6_5 from David Smiley [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=3176e65 ] LUCENE-7769 : UnifiedHighlighter wasn't seeing inside BoostQuery or SpanBoostQuery (cherry picked from commit 05b101f)

          People

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

            Dates

            • Created:
              Updated:
              Resolved:

              Development