lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Hostetter <hossman_luc...@fucit.org>
Subject SpanFirstQuery and SpanNotQuery
Date Sat, 29 Apr 2006 01:36:59 GMT

I'm looking at SpanQueries as I work on new test cases for LUCENE-557, and
I'm confused by the implimentation of SpanFirstQuery.getSpans().

In the Anonymous Spans instance returned, start() and end() are allways
the start() and end() of the inner SpanQuery for the current doc --
shouldn't the start() be "0" indicating that the span starts at the
begining of the document?

Because of the current implimentation, there doesn't seem to be any way to
use SpanNot with SpanFirst to ensure that a given SpanQuery X allways
occurs in the first N positions, and that SpanQuery Z does not appear
before it.

In other words, this...
   int N = ...
   SpanQuery X =...;
   SpanQuery Z =...;
   SpanQuery first = new SpanFirstQuery(X,N);
   SpanQuery q = new SpanNotQuery(first, Z);

...seems to be functionally equivilent to...
   int N = ...
   SpanQuery X =...;
   //SpanQuery Z =...;
   SpanQuery first = new SpanFirstQuery(X,N);
   SpanQuery q = first;

...is that how it's suppose to work, or am i missunderstanding something?

Here's a small addition to "TestBasics" which shows how i was
expecting things to work...

  public void testSpanNotFirst() throws Exception {
    SpanTermQuery term40 = new SpanTermQuery(new Term("field", "forty"));
    SpanFirstQuery first = new SpanFirstQuery(term40, 5);
    SpanTermQuery hun = new SpanTermQuery(new Term("field", "hundred"));
    SpanNotQuery not = new SpanNotQuery(first, hun);

    checkHits(not, new int[]{40,41,42,43,44,45,46,47,48,49});

  }


...but the results contain every number with a 4 in the tens digit



-Hoss


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message