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

Robert Muir commented on LUCENE-6393:
-------------------------------------

I used one final trick in the two-phase for FilterSpans:
{code}
  @Override
  public TwoPhaseIterator asTwoPhaseIterator() {
    final TwoPhaseIterator inner = in.asTwoPhaseIterator();
    if (inner != null) {
      // wrapped instance has an approximation
      return new TwoPhaseIterator(inner.approximation()) {
        @Override
        public boolean matches() throws IOException {
          return inner.matches() && twoPhaseCurrentDocMatches();
        }
      };
    } else {
      // wrapped instance has no approximation, but 
      // we can still defer matching until absolutely needed.
      return new TwoPhaseIterator(in) {
        @Override
        public boolean matches() throws IOException {
          return twoPhaseCurrentDocMatches();
        }
      };
    }
  }
{code}

This gives two-phase support for stuff like SpanFirst(SpanTerm). We may want to 
make this easier later (e.g. mandate approximations in Spans and give SpanTerm 
the obvious sorta-stupid implementation so code is easier). But for now lets 
get support in all the spans so we see what everything looks like.

> 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, 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