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

NPE in SpanNear when used as exclusion for SpanNot

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Duplicate
    • None
    • None
    • core/search
    • None

    Description

      It seems that if you try to use a SpanNear query as the "exclude" argument to a SpanNot query, you encounter an NPE. The stack trace looks like the following (as of trunk r398639) ...

      [junit] java.lang.NullPointerException
      [junit] at org.apache.lucene.search.spans.NearSpans.doc(NearSpans.java:227)
      [junit] at org.apache.lucene.search.spans.SpanNotQuery$1.next(SpanNotQuery.java:85)
      [junit] at org.apache.lucene.search.spans.SpanScorer.next(SpanScorer.java:51)
      [junit] at org.apache.lucene.search.Scorer.score(Scorer.java:47)
      [junit] at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:132)

      patch to TestBasics demonstrating bug will be attached shortly. I believe the problem is that SpanNotQuery$1 is calling "excludeSpans.doc()" without ever calling "excludeSpans.next()" ... this "works" when the exclude query is a TermQuery becuase the value returned by doc() is -1 ... but with SpanNearQuery tries to pop the initial value off of a queue which hasn't been initialized yet.

      Attachments

        1. LUCENE-560-test.patch
          1 kB
          Chris M. Hostetter
        2. LUCENE-560-test.patch
          2 kB
          Chris M. Hostetter

        Issue Links

          Activity

            People

              Unassigned Unassigned
              hossman Chris M. Hostetter
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: