Lucene - Core
  1. Lucene - Core
  2. LUCENE-5091

Modify SpanNotQuery to act as SpanNotNearQuery too

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 4.3.1
    • Fix Version/s: 4.5, 6.0
    • Component/s: core/search
    • Labels:
      None
    • Lucene Fields:
      New, Patch Available

      Description

      With very small modifications, SpanNotQuery can act as a SpanNotNearQuery.

      To find "a" but not if "b" appears 3 tokens before or 4 tokens after "a":
      new SpanNotQuery("a", "b", 3, 4)

      Original constructor still exists and calls SpanNotQuery("a", "b", 0, 0).

      Patch with tests on way.

      1. LUCENE-5091.patch
        13 kB
        David Smiley
      2. LUCENE-5091.patch.txt
        11 kB
        Tim Allison

        Issue Links

          Activity

          Hide
          Tim Allison added a comment -

          Patch attached. Let me know how this looks. Thank you!

          Show
          Tim Allison added a comment - Patch attached. Let me know how this looks. Thank you!
          Hide
          Tim Allison added a comment -

          With the push for 4.4 on, I've moved this to 4.5. If someone has a chance to review this, that'd be great. Thank you!

          Show
          Tim Allison added a comment - With the push for 4.4 on, I've moved this to 4.5. If someone has a chance to review this, that'd be great. Thank you!
          Hide
          David Smiley added a comment -

          Looks good, Tim, except for one thing: The way you incorporated pre & post into the hashCode is bad, as another unequal query with a pre and post values with flipped values would have the same hashCode. I'm consulting the other dev's on https://issues.apache.org/jira/browse/LUCENE-460?focusedCommentId=13712434&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13712434 on a suitable replacement, which will block me committing this for the moment.

          Also, I updated the package.html summary with a new description matching the class javadocs:

          <li>A {@link org.apache.lucene.search.spans.SpanNotQuery SpanNotQuery} removes spans
          matching one {@link org.apache.lucene.search.spans.SpanQuery SpanQuery} which overlap (or comes
          near) another.  This can be used, e.g., to implement within-paragraph
          search.</li>
          
          Show
          David Smiley added a comment - Looks good, Tim, except for one thing: The way you incorporated pre & post into the hashCode is bad, as another unequal query with a pre and post values with flipped values would have the same hashCode. I'm consulting the other dev's on https://issues.apache.org/jira/browse/LUCENE-460?focusedCommentId=13712434&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13712434 on a suitable replacement, which will block me committing this for the moment. Also, I updated the package.html summary with a new description matching the class javadocs: <li> A {@link org.apache.lucene.search.spans.SpanNotQuery SpanNotQuery} removes spans matching one {@link org.apache.lucene.search.spans.SpanQuery SpanQuery} which overlap (or comes near) another. This can be used, e.g., to implement within-paragraph search. </li>
          Hide
          David Smiley added a comment -

          The attached patch updates hashCode & equals. I'll commit this in a couple days if there are no changes needed.

          The changes.txt will be as follows, added to new features:

          • LUCENE-5091: SpanNotQuery can now be configured with pre and post slop to act as a hypothetical SpanNotNearQuery. (Tim Allison via David Smiley)
          Show
          David Smiley added a comment - The attached patch updates hashCode & equals. I'll commit this in a couple days if there are no changes needed. The changes.txt will be as follows, added to new features: LUCENE-5091 : SpanNotQuery can now be configured with pre and post slop to act as a hypothetical SpanNotNearQuery. (Tim Allison via David Smiley)
          Hide
          ASF subversion and git services added a comment -

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

          LUCENE-5091: add not-near capability to SpanNotQuery

          Show
          ASF subversion and git services added a comment - Commit 1507396 from David Smiley in branch 'dev/trunk' [ https://svn.apache.org/r1507396 ] LUCENE-5091 : add not-near capability to SpanNotQuery
          Hide
          David Smiley added a comment -

          Thanks Tim.

          Show
          David Smiley added a comment - Thanks Tim.
          Hide
          Steve Rowe added a comment -

          David Smiley, the JIRA workflow is: resolve on commit, close on release, but you closed on commit.

          Also, you have fix version as 4.5 and 5.0, but AFAICT you only committed to trunk?

          Show
          Steve Rowe added a comment - David Smiley , the JIRA workflow is: resolve on commit, close on release, but you closed on commit. Also, you have fix version as 4.5 and 5.0, but AFAICT you only committed to trunk?
          Hide
          David Smiley added a comment -

          Ugh, I mislabeled the commit message to the 4x branch, but it's there: https://svn.apache.org/viewvc?view=revision&revision=r1507397

          I'll re-open then resolve. Thanks for pointing this out.

          Show
          David Smiley added a comment - Ugh, I mislabeled the commit message to the 4x branch, but it's there: https://svn.apache.org/viewvc?view=revision&revision=r1507397 I'll re-open then resolve. Thanks for pointing this out.
          Hide
          Tim Allison added a comment -

          Thank you, David, for getting the hashcode right and for committing this!

          Show
          Tim Allison added a comment - Thank you, David, for getting the hashcode right and for committing this!
          Hide
          Adrien Grand added a comment -

          4.5 release -> bulk close

          Show
          Adrien Grand added a comment - 4.5 release -> bulk close
          Hide
          Tim Allison added a comment -

          Oops. Looks like LUCENE-5091 was a duplicate?

          Show
          Tim Allison added a comment - Oops. Looks like LUCENE-5091 was a duplicate?

            People

            • Assignee:
              David Smiley
              Reporter:
              Tim Allison
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development