lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Goddard, Michael J." <MICHAEL.J.GODD...@saic.com>
Subject Request for clarification on unordered SpanNearQuery
Date Thu, 04 Mar 2010 16:34:26 GMT
I've been working on some highlighting changes involving Spans (https://issues.apache.org/jira/browse/LUCENE-2287)
and could use some help understanding when overlapping Spans are valid.  To illustrate, I
added the test below to the TestSpans class; this test fails because there is no fourth range.

Am I wrong in my expectation that that last range would match?

Thanks.

  Mike


  // Doc 11 contains "t1 t2 t1 t3 t2 t3"
  public void testSpanNearUnOrderedOverlap() throws Exception {
    boolean ordered = false;
    int slop = 1;
    SpanNearQuery snq = new SpanNearQuery(
                              new SpanQuery[] {
                                makeSpanTermQuery("t1"),
                                makeSpanTermQuery("t2"),
                                makeSpanTermQuery("t3") },
                              slop,
                              ordered);
    Spans spans = snq.getSpans(searcher.getIndexReader());
    
    assertTrue("first range", spans.next());
    assertEquals("first doc", 11, spans.doc());
    assertEquals("first start", 0, spans.start());
    assertEquals("first end", 4, spans.end());
    
    assertTrue("second range", spans.next());
    assertEquals("second doc", 11, spans.doc());
    assertEquals("second start", 1, spans.start());
    assertEquals("second end", 4, spans.end());
    
    assertTrue("third range", spans.next());
    assertEquals("third doc", 11, spans.doc());
    assertEquals("third start", 2, spans.start());
    assertEquals("third end", 5, spans.end());
    
    // Question: why wouldn't this Span be found?
    assertTrue("fourth range", spans.next());
    assertEquals("fourth doc", 11, spans.doc());
    assertEquals("fourth start", 2, spans.start());
    assertEquals("fourth end", 6, spans.end());
    
    assertFalse("fifth range", spans.next());
  }


Mime
View raw message