FAQ
Hi All,

i have my own query parser which generates fuzzy/wildcard queries instances. It works fantastic, Lucene rocks ;-).
But i have to make sure the words are not to far apart.  I checked current proximity implementation. What i found is: PhraseQuery calculates a distance between terms (no fuzzy logic possible).
I have to calculate the distance (proximity) on the base of fuzzy queries.

Somebody  a idea how i can implement this feature?

Short example:
indexed string: "left word a b c d e f other right"
query string (fuzzy 0.5): "ohter word"
expected distance: 6

Many thanks!
___________________________________________________________
NEU: FreePhone - kostenlos mobil telefonieren und surfen!
Jetzt informieren: http://produkte.web.de/go/webdefreephone

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

Search Discussions

  • Robert Muir at Jan 16, 2011 at 5:51 pm

    On Sun, Jan 16, 2011 at 12:42 PM, Livia Hauser wrote:
    Hi All,

    i have my own query parser which generates fuzzy/wildcard queries instances. It works fantastic, Lucene rocks ;-).
    But i have to make sure the words are not to far apart.  I checked current proximity implementation. What i found is: PhraseQuery calculates a distance between terms (no fuzzy logic possible).
    I have to calculate the distance (proximity) on the base of fuzzy queries.

    Somebody  a idea how i can implement this feature?

    Short example:
    indexed string: "left word a b c d e f other right"
    query string (fuzzy 0.5): "ohter word"
    expected distance: 6
    I think you can do this with lucene's stable branch (what should be
    our next 3.1 release):
    http://svn.apache.org/repos/asf/lucene/dev/branches/branch_3x/

    Have a look at SpanMultiTermQueryWrapper: it allows you to rewrite any
    MultiTermQuery (such as Fuzzy/Wildcard) into a SpanQuery.
    For example in this case I think you would do:

    FuzzyQuery f1 = new FuzzyQuery(new Term("field", "ohter"));
    SpanQuery s1 = new SpanMultiTermQueryWrapper<FuzzyQuery>(f1);

    FuzzyQuery f2 = new FuzzyQuery(new Term("field", "word"));
    SpanQuery s2 = new SpanMultiTermQueryWrapper<FuzzyQuery>(f2);

    Now you can put the two spanqueries (s1 and s2) into a SpanNearQuery,
    and specify the maximum slop, and if they are required to be in order
    or not, etc etc.

    For more examples see the unit test:
    http://svn.apache.org/repos/asf/lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/spans/TestSpanMultiTermQueryWrapper.java

    ---------------------------------------------------------------------
    To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
    For additional commands, e-mail: java-user-help@lucene.apache.org
  • Livia Hauser at Jan 17, 2011 at 7:51 am
    Hi Robert,

    it looks really good!
    Many thanks!

    Regards,
    Livia


    -----Ursprüngliche Nachricht-----
    Von: "Robert Muir" &lt;rcmuir@gmail.com&gt;
    Gesendet: 16.01.2011 18:50:36
    An: java-user@lucene.apache.org
    Betreff: Re: how to implement a proximity search feature using Queries instead of terms
    On Sun, Jan 16, 2011 at 12:42 PM, Livia Hauser wrote:
    Hi All,

    i have my own query parser which generates fuzzy/wildcard queries instances. It works fantastic, Lucene rocks ;-).
    But i have to make sure the words are not to far apart.  I checked current proximity implementation. What i found is: PhraseQuery calculates a distance between terms (no fuzzy logic possible).
    I have to calculate the distance (proximity) on the base of fuzzy queries.

    Somebody  a idea how i can implement this feature?

    Short example:
    indexed string: "left word a b c d e f other right"
    query string (fuzzy 0.5): "ohter word"
    expected distance: 6
    I think you can do this with lucene's stable branch (what should be
    our next 3.1 release):
    http://svn.apache.org/repos/asf/lucene/dev/branches/branch_3x/

    Have a look at SpanMultiTermQueryWrapper: it allows you to rewrite any
    MultiTermQuery (such as Fuzzy/Wildcard) into a SpanQuery.
    For example in this case I think you would do:

    FuzzyQuery f1 = new FuzzyQuery(new Term("field", "ohter"));
    SpanQuery s1 = new SpanMultiTermQueryWrapper<FuzzyQuery>(f1);

    FuzzyQuery f2 = new FuzzyQuery(new Term("field", "word"));
    SpanQuery s2 = new SpanMultiTermQueryWrapper<FuzzyQuery>(f2);

    Now you can put the two spanqueries (s1 and s2) into a SpanNearQuery,
    and specify the maximum slop, and if they are required to be in order
    or not, etc etc.

    For more examples see the unit test:
    http://svn.apache.org/repos/asf/lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/spans/TestSpanMultiTermQueryWrapper.java

    ---------------------------------------------------------------------
    To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
    For additional commands, e-mail: java-user-help@lucene.apache.org
    ___________________________________________________________
    Empfehlen Sie WEB.DE DSL Ihren Freunden und Bekannten und wir
    belohnen Sie mit bis zu 50,- Euro! https://freundschaftswerbung.web.de

    ---------------------------------------------------------------------
    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
postedJan 16, '11 at 5:42p
activeJan 17, '11 at 7:51a
posts3
users2
websitelucene.apache.org

2 users in discussion

Livia Hauser: 2 posts Robert Muir: 1 post

People

Translate

site design / logo © 2022 Grokbase