Lucene LongField使用查询进行精确搜索 [英] Lucene LongField exact search with Query

查看:219
本文介绍了Lucene LongField使用查询进行精确搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用TermQuery完全匹配LongField?

How can I use a TermQuery to exactly match a LongField?

推荐答案

请考虑 注意:此API仅供内部使用,在下一版本中可能会以不兼容的方式进行更改.

我注意到这对于某些人来说是一个问题,因为NumericUtils API确实确实从

I've noticed this becoming a problem for some people, since the NumericUtils API did indeed change significantly from Version 3.6 to Version 4.0. I would recommend avoiding using it directly.

相反,请使用 NumericRangeQuery 搜索数值.可以通过将最大和最小范围设置为相等的值来获得精确的匹配.

Instead, use a NumericRangeQuery to search for numeric values. Precise matches can be obtained by setting maximum and minimum ranges to equal values.

此外,刻意选择哪些字段应为数字字段可能会有所帮助. NumericFields旨在允许数字范围查询和排序.如果您不需要使用它作为数字值进行搜索,则它可能不应该是NumericField.例如,识别号通常应该是关键字,而不是数字.

Also, deliberately selecting which fields should be numeric may be helpful. NumericFields are designed to allow numeric range querying and sorting. If you don't need to search using it as a numeric value, it probably shouldn't be a NumericField. Identification numbers, for instance, generally should be keywords, not numbers.

这篇关于Lucene LongField使用查询进行精确搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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