FAQ
Hello everyone,

I'm testing the use of proximity search operator (~) in Lucene.
I noticed a strange behaviour when the terms in the text are not in the same
order of the query.
Here are some examples:

text: AA BB
query: "AA BB"~0
result: true

text: AA ZZ BB
query: "AA BB"~0
result: false

text: AA ZZ BB
query: "AA BB"~1
result: true

text: BB AA
query: "AA BB"~0 why the result is false? Aren't BB AA contigous?
result: false

text: BB AA
query: "AA BB"~1
result: false

text: BB AA
query: "AA BB"~2 why with proximity=2 the result is true??
result: true

text: BB ZZ AA
query: "AA BB"~2
result: false

text: BB ZZ AA
query: "A B"~3 why with proximity=3 the result is true??
result: true

text: AA ZZ BB CC
query; "AA BB CC"~0
result: false

text: AA ZZ BB CC
query; "AA BB CC"~1
result: true

text: CC BB AA
query; "AA BB CC"~3
result: false

text: CC BB AA
query; "AA BB CC"~4
result: true

text: CC AA BB
query; "AA BB CC"~2
result: false

text: CC AA BB
query; "AA BB CC"~3
result: true

Does anyone know why Lucene behaves in that way??

Thanks,
Eng. Stefano Coppi

Information Systems Consultant

IC Technology s.r.l. - Gruppo InfoCamere SCpA
Via Bertolini, 37/C
70125 - Bari - Italy

Search Discussions

  • Yonik Seeley at May 29, 2008 at 1:55 am

    On Wed, May 28, 2008 at 5:36 AM, stefano coppi wrote:
    text: BB AA
    query: "AA BB"~0 why the result is false? Aren't BB AA contigous?
    result: false

    text: BB AA
    query: "AA BB"~1
    result: false

    text: BB AA
    query: "AA BB"~2 why with proximity=2 the result is true??
    result: true
    Sloppy phrase queries are ordered, and the slop is the allowable edit
    distance. So to get a match in your example, AA needs to move two
    spaces to the left (a slop of 2).

    Look at span queries if you need something unordered.

    -Yonik

    ---------------------------------------------------------------------
    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
postedMay 28, '08 at 9:36a
activeMay 29, '08 at 1:55a
posts2
users2
websitelucene.apache.org

2 users in discussion

Stefano coppi: 1 post Yonik Seeley: 1 post

People

Translate

site design / logo © 2022 Grokbase