简体   繁体   中英

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

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.

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.

您可能正在寻找词干: 使用Lucene创建英语单词 - 链接是Java,但您应该能够识别lucene .Net API的相应部分。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM