Lucene.net 模糊短语搜索
我自己已经尝试了相当长的一段时间,并在网络上到处寻找 - 但一直无法找到任何通过 Lucene.NET 2.9.2 进行模糊短语搜索的示例。 (C#)
是否能够建议如何详细执行此操作和/或提供一些示例代码 - 我将非常感谢任何帮助,因为我完全陷入困境?
I have tried this myself for a considerable period and looked everywhere around the net - but have been unable to find ANY examples of Fuzzy Phrase searching via Lucene.NET 2.9.2. ( C# )
Is something able to advise how to do this in detail and/or provide some example code - I would seriously seriously appreciate any help as I am totally stuck ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我假设您已经运行 Lucene 并创建了一个包含某些字段的搜索索引。因此,让我们进一步假设:
一旦您拥有了所有这些,您就可以继续在多个字段上定义搜索查询,如下所示:
也许您已经做到了这一点,只是缺少模糊部分。我只是简单地为
queryString
中的每个单词添加波浪线~
来告诉 Lucene 对 queryString 中的所有单词进行模糊搜索:这里的关键点是 Lucene 使用模糊仅搜索以
~
结尾的术语。发现了这个和一些更有用的信息http://scatteredcode.wordpress.com/2011/05/26/performing-a-fuzzy-search-with-multiple-terms-through-multiple-lucene-net-document-fields/ 。
I assume that you have Lucene running and created a search index with some fields in it. So let's assume further that:
Once you have all of these you can go ahead and define a search query on multiple fields like this:
Maybe you already got that far and are only missing the fuzzy part. I simply add a tilde
~
to every word in thequeryString
to tell Lucene to do a fuzzy search for all words in the queryString:The key point here is that Lucene uses fuzzy search only for terms that end with a
~
. That and some more helpful info was found onhttp://scatteredcode.wordpress.com/2011/05/26/performing-a-fuzzy-search-with-multiple-terms-through-multiple-lucene-net-document-fields/.