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

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

问题描述

我正在使用 Lucene 开发公司搜索 API.我的 Lucene 公司索引有 2 家公司:1.Abigail Adams National Bancorp, Inc.2.国民银行

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.....即.只应返回完全匹配.如何实现此功能?

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?

感谢阅读.

推荐答案

可以使用KeywordAnalyzer 来索引和搜索这个字段.关键字分析器将只为整个字符串生成一个标记.

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天全站免登陆