Lucene - Core
  1. Lucene - Core
  2. LUCENE-4861

can we use a single PostingsHighlighter for both whole and snippet highlighting?

    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

      Right now, because we pass the BreakIterator to the ctor, you have to make two instances if you sometimes want whole and sometimes want snippets.

      But I think this is a fairly common use case, eg I want entire title field (with matches highlighted) but I want body field (snippets + highlights). It would be nice to have this work with a single instance ...

        Activity

        Hide
        Robert Muir added a comment -

        maybe we can nuke breakiterator from the ctor alltogether and have something like:

        protected BreakIterator getBreakIterator(String field) {
          return BreakIterator.getSentenceInstance(Locale.ROOT);
        }
        

        we'd call this once per-request and remove the clone() we currently have. I think this is really fast
        with most of the JDK breakiterators and if someone has a heavy-duty custom one, they could just clone()
        from their own singleton themselves?

        Show
        Robert Muir added a comment - maybe we can nuke breakiterator from the ctor alltogether and have something like: protected BreakIterator getBreakIterator( String field) { return BreakIterator.getSentenceInstance(Locale.ROOT); } we'd call this once per-request and remove the clone() we currently have. I think this is really fast with most of the JDK breakiterators and if someone has a heavy-duty custom one, they could just clone() from their own singleton themselves?
        Hide
        Robert Muir added a comment -

        I think its also better if we fix some remaining issues in WholeBreakIterator and make it public rather than 'return null' here.

        I'll look at this thing and see if i can get it in shape.

        Show
        Robert Muir added a comment - I think its also better if we fix some remaining issues in WholeBreakIterator and make it public rather than 'return null' here. I'll look at this thing and see if i can get it in shape.
        Hide
        Robert Muir added a comment -

        I fixed this BreakIterator. I will wait on LUCENE-4860 to be committed first, then I think this issue is easy:
        we can just make it public and the API will be simple.

        Show
        Robert Muir added a comment - I fixed this BreakIterator. I will wait on LUCENE-4860 to be committed first, then I think this issue is easy: we can just make it public and the API will be simple.
        Hide
        Michael McCandless added a comment -

        +1

        Show
        Michael McCandless added a comment - +1
        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