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

Allow negative pre/post values in SpanNotQuery

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 6.4
    • Component/s: core/search
    • Labels:
      None
    • Lucene Fields:
      New

      Description

      I need to be able to specify a certain range of allowed overlap between the include and exclude parameters of SpanNotQuery.

      Since this behaviour is the inverse of the behaviour implemented by the pre and post constructor arguments, I suggest that this be implemented with negative pre and post values.

      Patch incoming.

      1. LUCENE-7431.patch
        10 kB
        Marc Morissette

        Activity

        Hide
        marc.morissette Marc Morissette added a comment - - edited

        Can I get a review of this patch please? It's rather small and includes tests.

        Show
        marc.morissette Marc Morissette added a comment - - edited Can I get a review of this patch please? It's rather small and includes tests.
        Hide
        dsmiley David Smiley added a comment -

        Patch looks pretty good; thanks.

        I was confused a little on the semantics but after a little experimentation, I get it. The "negative values" assert messages were sometimes inconsistent with the parameters, so I tweaked that, and I added a test line to help me understand something.
        final lines at end of testSpanNots:

            assertEquals("SpanNotS2S1NotXXNeg_0_0", 1, spanCount("s2 s1", 10, "xx", 0, 0));
            assertEquals("SpanNotS2S1NotXXNeg_1_1", 1, spanCount("s2 s1", 10, "xx", -1, -1));
            assertEquals("SpanNotS2S1NotXXNeg_0_2", 2, spanCount("s2 s1", 10, "xx",  0, -2));
            assertEquals("SpanNotS2S1NotXXNeg_1_2", 2, spanCount("s2 s1", 10, "xx", -1, -2));
            assertEquals("SpanNotS2S1NotXXNeg_2_1", 2, spanCount("s2 s1", 10, "xx", -2, -1));
            assertEquals("SpanNotS2S1NotXXNeg_3_1", 2, spanCount("s2 s1", 10, "xx", -3, -1));
            assertEquals("SpanNotS2S1NotXXNeg_1_3", 2, spanCount("s2 s1", 10, "xx", -1, -3));
            assertEquals("SpanNotS2S1NotXXNeg_2_2", 3, spanCount("s2 s1", 10, "xx", -2, -2));
        

        I'll commit the patch with this tweak early this coming week.

        Show
        dsmiley David Smiley added a comment - Patch looks pretty good; thanks. I was confused a little on the semantics but after a little experimentation, I get it. The "negative values" assert messages were sometimes inconsistent with the parameters, so I tweaked that, and I added a test line to help me understand something. final lines at end of testSpanNots: assertEquals( "SpanNotS2S1NotXXNeg_0_0" , 1, spanCount( "s2 s1" , 10, "xx" , 0, 0)); assertEquals( "SpanNotS2S1NotXXNeg_1_1" , 1, spanCount( "s2 s1" , 10, "xx" , -1, -1)); assertEquals( "SpanNotS2S1NotXXNeg_0_2" , 2, spanCount( "s2 s1" , 10, "xx" , 0, -2)); assertEquals( "SpanNotS2S1NotXXNeg_1_2" , 2, spanCount( "s2 s1" , 10, "xx" , -1, -2)); assertEquals( "SpanNotS2S1NotXXNeg_2_1" , 2, spanCount( "s2 s1" , 10, "xx" , -2, -1)); assertEquals( "SpanNotS2S1NotXXNeg_3_1" , 2, spanCount( "s2 s1" , 10, "xx" , -3, -1)); assertEquals( "SpanNotS2S1NotXXNeg_1_3" , 2, spanCount( "s2 s1" , 10, "xx" , -1, -3)); assertEquals( "SpanNotS2S1NotXXNeg_2_2" , 3, spanCount( "s2 s1" , 10, "xx" , -2, -2)); I'll commit the patch with this tweak early this coming week.
        Hide
        jira-bot ASF subversion and git services added a comment -

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

        LUCENE-7431: SpanNotQuery should support negative pre/post distance for overlap

        Show
        jira-bot ASF subversion and git services added a comment - Commit 750da7c5f7af74f2d9db36265639d7ae9dc9e4eb in lucene-solr's branch refs/heads/master from David Smiley [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=750da7c ] LUCENE-7431 : SpanNotQuery should support negative pre/post distance for overlap
        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit 55ed23168f6367e99b7d55fb63c7fa227aafa790 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=55ed231 ]

        LUCENE-7431: SpanNotQuery should support negative pre/post distance for overlap

        (cherry picked from commit 750da7c)

        Show
        jira-bot ASF subversion and git services added a comment - Commit 55ed23168f6367e99b7d55fb63c7fa227aafa790 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=55ed231 ] LUCENE-7431 : SpanNotQuery should support negative pre/post distance for overlap (cherry picked from commit 750da7c)
        Hide
        dsmiley David Smiley added a comment -

        Thanks Marc!

        Show
        dsmiley David Smiley added a comment - Thanks Marc!
        Hide
        marc.morissette Marc Morissette added a comment -

        Thanks David!

        Show
        marc.morissette Marc Morissette added a comment - Thanks David!

          People

          • Assignee:
            dsmiley David Smiley
            Reporter:
            marc.morissette Marc Morissette
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development