[英]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/ . 我们已经创建了lucene.net索引并基于此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: 要执行模糊搜索,您将创建一个
MultiFieldQueryParser
下面是一个如何执行此操作的示例:
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. 您的Lucene.Net版本可能会有所不同。
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. 浮点值
0.7f
是最小相似度。 You can tweak this number until you get the desired results. 您可以调整此数字,直到获得所需的结果。 The number cannot be more than
1.0f
. 数量不能超过
1.0f
。 Executing this query using an Lucene Searcher will give you the results you expect. 使用Lucene Searcher执行此查询将为您提供所期望的结果。
您可能正在寻找词干: 使用Lucene创建英语单词 - 链接是Java,但您应该能够识别lucene .Net API的相应部分。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.