开发者

Lucene Fuzzy Match on Phrase instead of Single Word

开发者 https://www.devze.com 2022-12-25 16:46 出处:网络
I\'m trying to do a fuzzy match on the Phrase \"Grand Prarie\" (deliberately misspel开发者_JAVA百科led) using Apache Lucene. Part of my issue is that the ~ operator only does fuzzy matches on single w

I'm trying to do a fuzzy match on the Phrase "Grand Prarie" (deliberately misspel开发者_JAVA百科led) using Apache Lucene. Part of my issue is that the ~ operator only does fuzzy matches on single word terms and behaves as a proximity match for phrases.

Is there a way to do a fuzzy match on a phrase with lucene?


Lucene 3.0 has ComplexPhraseQueryParser that supports fuzzy phrase query. This is in the contrib package.


Came across this through Google and felt solutions where not what I was after. In my case, solution was to simply repeat the search sequence against the solr API. So for example if I was looking for: title_t to include match for "dog~" and "cat~", I added some manual code to generate query as:

((title_t:dog~) and (title_t:cat~))

It might just be what above queries are about, however links seems dead.


There's no direct support for a fuzzy phrase, but you can simulate it by explicitly enumerating the fuzzy terms and then adding them to a MultiPhraseQuery. The resulting query would look like:

<MultiPhraseQuery: "grand (prarie prairie)">
0

精彩评论

暂无评论...
验证码 换一张
取 消