lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Goddard, Michael J." <>
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 (
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?



  // 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("t3") },
    Spans spans = snq.getSpans(searcher.getIndexReader());
    assertTrue("first range",;
    assertEquals("first doc", 11, spans.doc());
    assertEquals("first start", 0, spans.start());
    assertEquals("first end", 4, spans.end());
    assertTrue("second range",;
    assertEquals("second doc", 11, spans.doc());
    assertEquals("second start", 1, spans.start());
    assertEquals("second end", 4, spans.end());
    assertTrue("third range",;
    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",;
    assertEquals("fourth doc", 11, spans.doc());
    assertEquals("fourth start", 2, spans.start());
    assertEquals("fourth end", 6, spans.end());
    assertFalse("fifth range",;

View raw message