Solr
  1. Solr
  2. SOLR-6281

PostingsSolrHighlighter should be more configurable

    Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 4.10, 6.0
    • Component/s: highlighter
    • Labels:
      None

      Description

      The DefaultSolrHighlighter (works on non-FVH and FVH modes) and PostingsSolrHighlighter are quite different, although they do share some highlighting parameters where it's directly applicable. DSH has its fragListBuilder, fragmentsBuilder, boundaryScanner, configurable by letting you defined your own class in solrconfig.xml. PSH does not; it uses the Lucene default implementations of DefaultPassageFormatter, PassageScorer, and Java BreakIterator, though it configures each of them based on options. I have a case where I need to provide a custom PassageFormatter, for example.

        Activity

        Hide
        David Smiley added a comment -

        A simple good-enough solution is to make the inner class extending PostingsHighlighter delegate out to protected methods on PSH for getting & initializing the PassageFormatter and a few other things. Then I could extend PostingsSolrHighlighter to override the method.

        Following from that step, the components could have their classes declared in solrconfig.xml. But that would probably mean a new SolrPassageFormatter class. I'm not sure if I want to bother going that far down the configurability road right now.

        As an aside... it's a shame that these different highlighters don't share more abstractions and terminology that seem orthogonal. That is, a "Passage" is conceptually the same as "Fragment". I appreciate that different highlighters work differently and thus have somewhat different data associated with them.

        Show
        David Smiley added a comment - A simple good-enough solution is to make the inner class extending PostingsHighlighter delegate out to protected methods on PSH for getting & initializing the PassageFormatter and a few other things. Then I could extend PostingsSolrHighlighter to override the method. Following from that step, the components could have their classes declared in solrconfig.xml. But that would probably mean a new SolrPassageFormatter class. I'm not sure if I want to bother going that far down the configurability road right now. As an aside... it's a shame that these different highlighters don't share more abstractions and terminology that seem orthogonal. That is, a "Passage" is conceptually the same as "Fragment". I appreciate that different highlighters work differently and thus have somewhat different data associated with them.
        Hide
        David Smiley added a comment -

        In the attached patch, I made the anonymous inner class non-anonymous "SolrExtendedPostingsHighlighter" (so that it can be extended) and instantiated via a new method getHighlighter(req) that can be overridden. And I made a minor refactoring to reduce indentation levels, plus added a TODO as I observed this highlighter does not use the logic in DefaultSolrHighlighter.alternateField().

        I'll commit this in a couple days.

        Show
        David Smiley added a comment - In the attached patch, I made the anonymous inner class non-anonymous "SolrExtendedPostingsHighlighter" (so that it can be extended) and instantiated via a new method getHighlighter(req) that can be overridden. And I made a minor refactoring to reduce indentation levels, plus added a TODO as I observed this highlighter does not use the logic in DefaultSolrHighlighter.alternateField(). I'll commit this in a couple days.
        Hide
        ASF subversion and git services added a comment -

        Commit 1614702 from David Smiley in branch 'dev/trunk'
        [ https://svn.apache.org/r1614702 ]

        SOLR-6281: Made PostingsSolrHighlighter more configurable

        Show
        ASF subversion and git services added a comment - Commit 1614702 from David Smiley in branch 'dev/trunk' [ https://svn.apache.org/r1614702 ] SOLR-6281 : Made PostingsSolrHighlighter more configurable
        Hide
        ASF subversion and git services added a comment -

        Commit 1614704 from David Smiley in branch 'dev/branches/branch_4x'
        [ https://svn.apache.org/r1614704 ]

        SOLR-6281: Made PostingsSolrHighlighter more configurable

        Show
        ASF subversion and git services added a comment - Commit 1614704 from David Smiley in branch 'dev/branches/branch_4x' [ https://svn.apache.org/r1614704 ] SOLR-6281 : Made PostingsSolrHighlighter more configurable

          People

          • Assignee:
            David Smiley
            Reporter:
            David Smiley
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development