Lucene - Core
  1. Lucene - Core
  2. LUCENE-4860

PostingsHighlighter should pass field name to PassageFormatter.format?

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 4.3, 6.0
    • Component/s: None
    • Labels:
      None
    • Lucene Fields:
      New

      Description

      If the app needs to render different fields (eg multi-valued vs single-valued) differently it's tricky now.

      You can do Passage[0].getMatchTerms()[0].field(), but then that doesn't work if that field hit the empty highlight.

      I think we should pass the fieldName to format directly? And then maybe change getMatchTerms() to return BytesRef[] instead (the field name is redundant: they are all the same for all passages passed to format).

      1. LUCENE-4860.patch
        16 kB
        Michael McCandless
      2. LUCENE-4860.patch
        15 kB
        Michael McCandless
      3. LUCENE-4860.patch
        15 kB
        Michael McCandless
      4. LUCENE-4860.patch
        10 kB
        Michael McCandless

        Activity

        Hide
        Robert Muir added a comment -

        Yeah the current API is bogus. The idea of the getMatchTerms was just thinking about different terms having different colors, but the API was never adjusted after multiple fields were added to this thing.

        So I think passing fieldName + changing matchTerms to just be the bytes sounds good.

        Alternatively we could put fieldName in the passage too, but thats confusing because you have N of them.

        Show
        Robert Muir added a comment - Yeah the current API is bogus. The idea of the getMatchTerms was just thinking about different terms having different colors, but the API was never adjusted after multiple fields were added to this thing. So I think passing fieldName + changing matchTerms to just be the bytes sounds good. Alternatively we could put fieldName in the passage too, but thats confusing because you have N of them.
        Hide
        Michael McCandless added a comment -

        Here's one possible approach ... it just add .getFormatter/.getScorer each taking String field, so subclass can pick an impl up front depending on the field name.

        Show
        Michael McCandless added a comment - Here's one possible approach ... it just add .getFormatter/.getScorer each taking String field, so subclass can pick an impl up front depending on the field name.
        Hide
        Michael McCandless added a comment -

        New patch, cutting Passage.getMatchTerms from Term[] -> BytesRef[].

        Show
        Michael McCandless added a comment - New patch, cutting Passage.getMatchTerms from Term[] -> BytesRef[].
        Hide
        Michael McCandless added a comment -

        Patch, creating & reusing the default PassageScorer/Formater once per highlight request ...

        I think it's ready.

        Show
        Michael McCandless added a comment - Patch, creating & reusing the default PassageScorer/Formater once per highlight request ... I think it's ready.
        Hide
        Michael McCandless added a comment -

        New patch, adding back lost assert in one test and adding back null check for the scorer...

        Show
        Michael McCandless added a comment - New patch, adding back lost assert in one test and adding back null check for the scorer...
        Hide
        Robert Muir added a comment -

        +1

        Show
        Robert Muir added a comment - +1
        Hide
        Commit Tag Bot added a comment -

        [trunk commit] Michael McCandless
        http://svn.apache.org/viewvc?view=revision&revision=1459816

        LUCENE-4860: per-field control over scoring and formatting

        Show
        Commit Tag Bot added a comment - [trunk commit] Michael McCandless http://svn.apache.org/viewvc?view=revision&revision=1459816 LUCENE-4860 : per-field control over scoring and formatting
        Hide
        Commit Tag Bot added a comment -

        [branch_4x commit] Michael McCandless
        http://svn.apache.org/viewvc?view=revision&revision=1459817

        LUCENE-4860: per-field control over scoring and formatting

        Show
        Commit Tag Bot added a comment - [branch_4x commit] Michael McCandless http://svn.apache.org/viewvc?view=revision&revision=1459817 LUCENE-4860 : per-field control over scoring and formatting
        Hide
        Uwe Schindler added a comment -

        Closed after release.

        Show
        Uwe Schindler added a comment - Closed after release.

          People

          • Assignee:
            Michael McCandless
            Reporter:
            Michael McCandless
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development