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 ik...@daegis.com on 2011/08/23 00:18:15 UTC

SpanNearQuery vs. PhraseQuery.setSlop

Hello,
We are using phrase queries with a slop value to perform Near and Within style searches and the issue we are encountering is as follows:

Since the slop value in the PhraseQuery is the edit-distance, a message with the terms  'thank' and 'you' will be found with a query of field:"thank you"~1 but will not be found with a query of field:"you thank"~1. Currently to work around this nuance I am creating a new query of field:("you thank"~1 OR "thank you"~1).

Can I solve this by constructing a SpanNearQuery with two SpanTermQuery("thank") and SpanTermQuery("you") and a slop value of 1 and the ordering of false?

Thanks,
Ian Koelliker

Re: SpanNearQuery vs. PhraseQuery.setSlop

Posted by Saurabh Gokhale <sa...@gmail.com>.
Yes, this can be achieved using SpanNearQuery with inOrder flag (third
argument to the constructor) set to false.

there is a good example (Listing 5.10) in Lucene in action if you want to
take a look.

Thanks

Saurabh

On Mon, Aug 22, 2011 at 5:18 PM, <ik...@daegis.com> wrote:

> Hello,
> We are using phrase queries with a slop value to perform Near and Within
> style searches and the issue we are encountering is as follows:
>
> Since the slop value in the PhraseQuery is the edit-distance, a message
> with the terms  'thank' and 'you' will be found with a query of field:"thank
> you"~1 but will not be found with a query of field:"you thank"~1. Currently
> to work around this nuance I am creating a new query of field:("you thank"~1
> OR "thank you"~1).
>
> Can I solve this by constructing a SpanNearQuery with two
> SpanTermQuery("thank") and SpanTermQuery("you") and a slop value of 1 and
> the ordering of false?
>
> Thanks,
> Ian Koelliker
>