how to do fuzzy search in Lucene.net in asp.net?

不想你离开。 提交于 2019-12-10 15:46:16

问题


we have creating lucene.net index and search based on this URL http://sonyblogpost.blogspot.in/. but we want the output like follow.

example: if i search "featured" i want to show related terms like "featured","featuring","feature".

Anyone can help me. thanks.


回答1:


To perform a Fuzzy search you'll create a MultiFieldQueryParser Below is an example on how to do this:

var parser = new MultiFieldQueryParser(Lucene.Net.Util.Version.LUCENE_29, new[] { "field1", "field2" }, new StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_29));

Your version of Lucene.Net may vary.

Next you will get a Fuzzy query from the parser like this:

var query = parser.GetFuzzyQuery("fieldName", "featured", 0.7f);

The float value of 0.7f is the minimum similarity. You can tweak this number until you get the desired results. The number cannot be more than 1.0f. Executing this query using an Lucene Searcher will give you the results you expect.




回答2:


You're probably looking for stemming: Stemming English words with Lucene - The link is Java, but you should be able to identify the corresponding parts of the lucene .Net API.



来源:https://stackoverflow.com/questions/18851208/how-to-do-fuzzy-search-in-lucene-net-in-asp-net

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!