“Did you mean?” feature in Lucene.net

后端 未结 4 2236
野的像风
野的像风 2020-11-30 22:07

Can someone please let me know how do I implement \"Did you mean\" feature in Lucene.net?

Thanks!

4条回答
  •  醉话见心
    2020-11-30 22:50

    AFAIK Lucene supports proximity-search, meaning that if you use something like:

    field:stirng~0.5

    (it s a tilde-sign)

    will match "string". the float is how "tolerant" the search would be, where 1.0 is exact match and 0.0 is match everything (sort of).

    Different parsers will however implement this differently.

    A proximity-search is much slower than a fuzzy-search (stri*) so use it with caution. In your case, one would assume that if you find no matches on a regular search, you try a proximity-search to see what you find, and present "did you mean" based on the result somehow.

    Might be useful to cache this sort of lookups for very common mispellings, for performance reasons.

提交回复
热议问题