“Did you mean?” feature in Lucene.net

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

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

Thanks!

4条回答
  •  萌比男神i
    2020-11-30 22:51

    Google's "Did you mean?" is (probably; they're secretive, of course) implemented by consulting their query log. Look to see if people who searched for the query you're processing searched for something very similar soon after; if so, it indicates they made a mistake, and realized what they ought to be searching for.

    Since you probably don't have a huge query log, you could approximate it. Take the query, split up the terms, see if there are any similar terms in the database (by edit distance, whatever); replace your terms with those nearby terms, and rerun the query. If you get more hits, that was probably a better query. Suggest it to the user. (And since you've already got the hits, and most people only look at the top 2 results, show them those.)

提交回复
热议问题