Lucene - Core
  1. Lucene - Core
  2. LUCENE-3141

FastVectorHighlighter - expose FieldFragList.fragInfo for user-customizable FragmentsBuilder

    Details

    • Lucene Fields:
      New, Patch Available

      Description

      Needed to build a custom highlightable snippet - snippet should start with the sentence containing the first match, then continue for 250 characters.

      So created a custom FragmentsBuilder extending SimpleFragmentsBuilder and overriding the createFragments(IndexReader reader, int docId, String fieldName, FieldFragList fieldFragList) method - unit test containing the code is attached to the JIRA.

      To get this to work, needed to expose (make public) the FieldFragList.fragInfo member variable. This is currently package private, so only FragmentsBuilder implementations within the lucene-highlighter o.a.l.s.vectorhighlight package (such as SimpleFragmentsBuilder) can access it. Since I am just using the lucene-highlighter.jar as an external dependency to my application, the simplest way to access FieldFragList.fragInfo in my class was to make it public.

      1. LIABookTest.java
        38 kB
        Sujit Pal
      2. LIABookTest.java
        38 kB
        Sujit Pal
      3. LUCENE-3141.patch
        13 kB
        Koji Sekiguchi
      4. lucene-3141-patch.diff
        0.6 kB
        Sujit Pal
      5. lucene-3141-patch-2.diff
        0.7 kB
        Sujit Pal

        Activity

        Hide
        Sujit Pal added a comment -

        1) Patch of the change to FieldFragList (taken from the root of the 3.1 release branch (svn co http://svn.apache.org/repos/asf/lucene/dev/tags/lucene_solr_3_1/)

        Show
        Sujit Pal added a comment - 1) Patch of the change to FieldFragList (taken from the root of the 3.1 release branch (svn co http://svn.apache.org/repos/asf/lucene/dev/tags/lucene_solr_3_1/ )
        Hide
        Sujit Pal added a comment -

        Unit test demonstrating use of the FieldFragList.fragInfo by an external (out of vectorhighlight package) FragmentsBuilder.

        Show
        Sujit Pal added a comment - Unit test demonstrating use of the FieldFragList.fragInfo by an external (out of vectorhighlight package) FragmentsBuilder.
        Hide
        Koji Sekiguchi added a comment -

        Can you rewrite the patch using getter method? I'm willing to commit soon. Thanks.

        Show
        Koji Sekiguchi added a comment - Can you rewrite the patch using getter method? I'm willing to commit soon. Thanks.
        Hide
        Sujit Pal added a comment -

        Path restoring fragInfos to package protected and exposing a getter method getFragInfos() instead per Koji's recommendation.

        Show
        Sujit Pal added a comment - Path restoring fragInfos to package protected and exposing a getter method getFragInfos() instead per Koji's recommendation.
        Hide
        Sujit Pal added a comment -

        Modified test case (to verify patch) to work against modified patch.

        Show
        Sujit Pal added a comment - Modified test case (to verify patch) to work against modified patch.
        Hide
        Sujit Pal added a comment -

        Adding same patch again, this time with "Grant License to ASF..." checked (forgot about it the last time).

        Show
        Sujit Pal added a comment - Adding same patch again, this time with "Grant License to ASF..." checked (forgot about it the last time).
        Hide
        Sujit Pal added a comment -

        Thanks Koji, I have attached the updated patch (lucene-3141-patch-2.diff) and the updated test case (LIABookTest.java).

        Show
        Sujit Pal added a comment - Thanks Koji, I have attached the updated patch (lucene-3141-patch-2.diff) and the updated test case (LIABookTest.java).
        Hide
        Koji Sekiguchi added a comment -

        I changed the member private and used the new getter method in vectorhighlight package. Will commit shortly.

        Show
        Koji Sekiguchi added a comment - I changed the member private and used the new getter method in vectorhighlight package. Will commit shortly.
        Hide
        Koji Sekiguchi added a comment -

        trunk: Committed revision 1128549.
        3x: Committed revision 1128550.

        Show
        Koji Sekiguchi added a comment - trunk: Committed revision 1128549. 3x: Committed revision 1128550.
        Hide
        Sujit Pal added a comment -

        Thank you, I see it on the trunk now.

        Show
        Sujit Pal added a comment - Thank you, I see it on the trunk now.
        Hide
        Robert Muir added a comment -

        bulk close for 3.3

        Show
        Robert Muir added a comment - bulk close for 3.3

          People

          • Assignee:
            Koji Sekiguchi
            Reporter:
            Sujit Pal
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development