[ 
https://issues.apache.org/jira/browse/LUCENE-6393?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14395914#comment-14395914
 ] 

Paul Elschot commented on LUCENE-6393:
--------------------------------------

A first impression the alternative patch.
In case for Spans it makes sense to enforce two phase iteration everywhere 
except in TermSpans, it could be done in for example in an abstract class 
TwoPhaseSpans (a Spans subclass) that should then be used for all other Spans 
than TermSpans.
Doing that in FilterSpans as in the alternative patch could be a first step for 
that.

About this TODO:
{code}
// TODO: can/should we combine this with the logic above?
+    public boolean twoPhaseCurrentDocMatches
{code}
Such sharing can be done by calling this twoPhaseCurrentDocMatches from the 
toMatchDoc method that is normally used at the end of nextDoc() and advance(). 
The SpanContain... queries at LUCENE-6083 have this in ContainSpans.java:
{code}
+  @Override
+  int toMatchDoc() throws IOException {
+    oneExhaustedInCurrentDoc = false;
+    while (true) {
+      if (twoPhaseCurrentDocMatches()) {
+        return docID();
+      }
+      if (nextDoc() == NO_MORE_DOCS) {
+        return NO_MORE_DOCS;
+      }
+    }
+  }
{code}
I tried to share the same method also with the NearSpansUn/Ordered classes, but 
when I did that some tests failed (maybe because the atFirstInCurrentDoc flag 
is not yet handled correctly.)



> SpanFirstQuery sometimes returns Spans without any positions
> ------------------------------------------------------------
>
>                 Key: LUCENE-6393
>                 URL: https://issues.apache.org/jira/browse/LUCENE-6393
>             Project: Lucene - Core
>          Issue Type: Bug
>            Reporter: Robert Muir
>             Fix For: Trunk, 5.2
>
>         Attachments: LUCENE-6393-alternative.patch, LUCENE-6393.patch, 
> LUCENE-6393.patch
>
>
> This hits an assert in SpanScorer because it breaks the javadocs contract of 
> Spans.nextStartPosition():
>    * Returns the next start position for the current doc.
>    * There is always *at least one start/end position* per doc.
>    * After the last start/end position at the current doc this returns 
> NO_MORE_POSITIONS.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to