使用 Lucene .NET 自动完成地址
我还没能确定这一点。我尝试了几种不同的分析仪,它们都让我接近,但不完全是我想要的。目前还不能选择使用 SOLR。
我想要的一个例子:
Input: 200
Matches: 200 E Dragon Dr.
200 W Paragon Rd.
200 Lick Skillet Dr.
Input: 200 E
Matches: 200 E Dragon Dr.
200 E Toll Rd.
Input: 200 E D
Matches: 200 E Dragon Dr.
如果我使用简单的分析器,那么它在数字上将不匹配。空白分析器仅使用数字即可获得所需的效果,但是一旦我添加 E,它就不会按我的预期返回。最好的分析器是什么,或者我使用了错误的查询?
谢谢,
编辑:
我已经接受了下面的答案,并进行了大量的谷歌搜索,我正在接近使用查询解析器和空白分析器。我只是让查询解析器确定最佳查询,它似乎可以工作。
I have not been able to get this nailed down. I have tried several different analyzers and they all get me close, but not exactly what I want. Using SOLR is not an option at the moment.
An examples of what I would like:
Input: 200
Matches: 200 E Dragon Dr.
200 W Paragon Rd.
200 Lick Skillet Dr.
Input: 200 E
Matches: 200 E Dragon Dr.
200 E Toll Rd.
Input: 200 E D
Matches: 200 E Dragon Dr.
If I use the simple analyzer then it will not match on the number. The whitespace analyzer gets the desired effect with just the number, but once I add the E it does not return as I expect. What would be the best analyzer or am I using the wrong queries?
Thanks,
EDIT:
I have taken the below answer and did a ton of googling and I am getting close just using the query parser and the whitespaceanalyzer. I am just letting the query parser determine the best query and it seems to work.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试使用关键字分析器和查询解析器来搜索 Lucene 中的地址字段。我正在使用 MultiFieldQueryParser,但您也可以使用常规查询解析器:
try using a keyword analyzer and a query parser to search an address field in Lucene. I am using a MultiFieldQueryParser, but you could use a regular query parser too: