On Apr 11, 2006, at 11:56 AM, Doug Cutting wrote:
Erik Hatcher wrote:
I have a potential need for a SpanNearQuery with an exact non- zero gap specified

Ironically, you can now easily specify this with PhraseQuery, but not with SpanNearQuery. You can construct a phrase query with explicit positions, e.g.:

PhraseQuery pq = new PhraseQuery();
pq.add(new Term("f", "x"), 0);
pq.add(new Term("f", "y"), 2);

This will match instances of "x" and "y" with exactly one word between them in field "f".

Unfortunately one cannot (yet) construct a SpanNearQuery with explicit positions. I think that would be useful, and not too hard to add. Internally all the computation is in terms of positions, so adding this is mostly a matter of exposing this in the public API.

Would this be as easy as modifying SpanNearQuery to have a minimum and maximum slop feature, and modifying NearSpans.checkSlop() to add a condition that the difference is >= the minimum slop? At first glance it seems so, but I want to be sure I'm not missing something.

If you want to match something like "a ? b ? ? c", where "?" matches any word, then slop is not sufficient, you really need explicit positions, or else you'll match things like "a ? ? b ? c".

In my case, I was thinking of joining two zero-slopped SpanNearQuerys within an outer SpanNearQuery with a slop of _exactly_ one, so it'd be like this: (a b) ? (c d)

I'll dig into this further when the project demands, and am glad to confirm that it won't be too difficult to implement if/when the need arises.

        Erik


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to