FAQ
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

Search Discussions

  • Chris Hostetter at Sep 20, 2007 at 10:20 pm
    : 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
  • Sonu SR at Sep 21, 2007 at 4:05 am
    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 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
  • Chris Hostetter at Sep 21, 2007 at 5:31 am
    : 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
  • Sonu SR at Sep 21, 2007 at 1:15 pm
    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 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

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupjava-user @
categorieslucene
postedSep 20, '07 at 1:55p
activeSep 21, '07 at 1:15p
posts5
users2
websitelucene.apache.org

2 users in discussion

Sonu SR: 3 posts Chris Hostetter: 2 posts

People

Translate

site design / logo © 2022 Grokbase