You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Lucene <Lu...@roylip.ftech.net> on 2004/07/30 16:01:54 UTC

Proximity searching and phrase

Hi,

I was wondering is there is a way to do proximity searches with phrases
eg "very good" NEAR "sometimes".

Any help on this would be welcome.

Many thanks,


Roy


Re: Proximity searching and phrase

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
On Jul 30, 2004, at 7:01 AM, Lucene wrote:
> I was wondering is there is a way to do proximity searches with phrases
> eg "very good" NEAR "sometimes".
>
> Any help on this would be welcome.

You can do this with the new SpanQuery family in v1.4.  The example you 
gave would consist of a SpanTermQuery for "very", "good", and 
"sometimes", with the first two combined with a SpanNearQuery (with no 
slop, in order), and finally the "very good" SpanNearQuery combined 
with another SpanNearQuery with the "sometimes" SpanTermQuery.  *whew* 
:)

There is no QueryParser support (yet) for such constructs, so doing 
this with the API directly is necessary.  There has been a contribution 
of a new parser that can work with SpanQuery which probably should be 
put in the sandbox soon.

	Erik


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