使用Lucene搜索API查找完全匹配 [英] Finding exact match using Lucene search API

查看:224
本文介绍了使用Lucene搜索API查找完全匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Lucene开发公司搜索API. 我的Lucene公司指数有2家公司: 1,阿比盖尔·亚当斯国家银行公司 2.National Bancorp

I'm working on a company search API using Lucene. My Lucene company index has got 2 companies: 1.Abigail Adams National Bancorp, Inc. 2.National Bancorp

如果用户键入National Bancorp,则仅应返回公司2(即National Bancorp),而不应返回#1 ... ie.仅返回完全匹配的内容. 如何实现此功能?

If the user types in National Bancorp, then only company # 2(ie. National Bancorp) should be returned and not #1.....ie. only exact matches should be returned. How do I achieve this functionality?

感谢阅读.

推荐答案

您可以使用

You can use KeywordAnalyzer to index and search on this field. Keyword Analyzer will generate only one token for the entire string.

这篇关于使用Lucene搜索API查找完全匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆