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 Sonu SR <so...@gmail.com> on 2007/09/20 15:55:09 UTC

Question regarding proximity search

Hi,
I have a doubt on proximity search.
Is the query "cat dog"~6 same as (cat dog)~6 ?
I think both case will search for "cat" and "dog" within 6 words each other.
But I am getting different number of results for the above queries. The
second one may be the higher. Please clarify this.

Thanks,
Sonu

Re: Question regarding proximity search

Posted by Sonu SR <so...@gmail.com>.
Yes, I understood what you said. What I meant is, since i am using Lucene
2.1, I don't get the parse exception. So I thought it's working just like
using quotes.

Thanks,
Sonu

On 9/21/07, Chris Hostetter <ho...@fucit.org> wrote:
>
>
> : I checked the lucene converted syntax (using Query.toString()) in both
> case
> : and found the second one actually not converting to proximity query.
>
> I don't think you understood what I was trying to say...
>
> using parens with a "~" character after it is not currently, and has never
> been (to my knowledge) a means of creating a "proximity query".  It is not
> documented in 2.2, 2.1, 2.0, 1.9, or 1.4.3.  It is not legal syntax in 2.2
> (it causes a parse exception).  In lucene, the way to do proximity based
> queries is either with SpanNearQueries, or with PhraseQueries -- the way
> to create a PhraseQuery using hte Lucene QueryParser is with quote
> character '"'
>
> there is no reason why you should expect:  (cat dog)~3   to create a
> proximity query.
>
>
>
> -Hoss
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>

Re: Question regarding proximity search

Posted by Chris Hostetter <ho...@fucit.org>.
: I checked the lucene converted syntax (using Query.toString()) in both case
: and found the second one actually not converting to proximity query.

I don't think you understood what I was trying to say...

using parens with a "~" character after it is not currently, and has never 
been (to my knowledge) a means of creating a "proximity query".  It is not 
documented in 2.2, 2.1, 2.0, 1.9, or 1.4.3.  It is not legal syntax in 2.2 
(it causes a parse exception).  In lucene, the way to do proximity based 
queries is either with SpanNearQueries, or with PhraseQueries -- the way 
to create a PhraseQuery using hte Lucene QueryParser is with quote 
character '"'

there is no reason why you should expect:  (cat dog)~3   to create a 
proximity query.



-Hoss


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


Re: Question regarding proximity search

Posted by Sonu SR <so...@gmail.com>.
Thanks Hoss, for the reply. I am using Lucene 2.1.
I checked the lucene converted syntax (using Query.toString()) in both case
and found the second one actually not converting to proximity query.

"cat dog"~6 is converted to ABST:"cat dog"~4 and
(cat dog)~6 is converted to +ABST:cat +ABST:dog.

That is discarding the proximity operator in the second case.


On 9/21/07, Chris Hostetter <ho...@fucit.org> wrote:
>
>
> : Is the query "cat dog"~6 same as (cat dog)~6 ?
> : I think both case will search for "cat" and "dog" within 6 words each
> other.
> : But I am getting different number of results for the above queries. The
> : second one may be the higher. Please clarify this.
>
> i don't believe:    (cat dog)~6     is even a legal query in the Lucene
> QueryParser sytnax ... it isn't documented, and it doesn't work in Lucene
> 2.2.
>
>
>
> -Hoss
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>

Re: Question regarding proximity search

Posted by Chris Hostetter <ho...@fucit.org>.
: Is the query "cat dog"~6 same as (cat dog)~6 ?
: I think both case will search for "cat" and "dog" within 6 words each other.
: But I am getting different number of results for the above queries. The
: second one may be the higher. Please clarify this.

i don't believe:    (cat dog)~6     is even a legal query in the Lucene 
QueryParser sytnax ... it isn't documented, and it doesn't work in Lucene 2.2.



-Hoss


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