lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Elschot <>
Subject Re: Adding support for NOT NEAR construct?
Date Wed, 17 Oct 2007 18:45:47 GMT

One can use SpanNotQuery to get NOT NEAR by using this generalized structure:

SpanNot(foo, SpanNear(foo, bar, distance))

This also allows for example:

SpanNot(two, SpanNear(one, three, distance))

Btw. I don't know of any query language that has this second form.

AND NOT normally does not work for this because it works on doc level
and not within the matching text of a field.

Paul Elschot

On Wednesday 17 October 2007 17:57:21 Dave Golombek wrote:
> We've run into a situation where having "NOT NEAR" queries would really
> help. I haven't been able to find any discussion of adding this to Lucene
> in the past, so wanted to ask if people had any comments about it before I
> started trying to make the change.
> I've looked at NearSpansUnordered and it seems that reversing the logic in
> atMatch() would go a long way towards implementation; NearSpansOrdered is a
> bit harder, depending upon the exact semantics of "NOT NEAR" that we want
> to implement. For queries, I was thinking that either "foo bar"~-10  or
> "foo bar"!~10 might be reasonable; the former should be pretty easy to
> parse.
> Does this sound reasonable? Something for contrib?
> Thanks,
> Dave Golombek
> Senior Software Engineer
> Black Duck Software, Inc.
> T +1.781.810.2079
> F +1.781.891.5145
> C +1.617.230.5634
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message