Lucene 查询语言和数值范围 [英] Lucene query language and numeric range

查看:26
本文介绍了Lucene 查询语言和数值范围的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在应用以下 Lucene 查询谓词以获取 2 到 6 范围内的所有包含数字:

I'm applying the following Lucene query predicate in order to get all inclusive numbers in 2 to 6 range:

value:[2 TO 6]

并接收具有以下值的文档:

and receive the documents with the following values:

567986400000
567986400000
567986400000
536450400000
536450400000
599608800000
536450400000
567986400000

我对数值范围查询很感兴趣,显然,例如 Long567986400000 不在 [2 TO 6] 的范围内.看起来范围搜索是字符串,我不知道如何在我的应用程序中针对不同的数值解决它.

I'm interested in the numeric range query and obviously, for example, the Long value 567986400000 is not in the range of [2 TO 6]. Looks like the range searches are strings and I don't know how to workaround it in mine application for the different numeric values.

如何在 Lucene 中正确使用数值范围查询?

How to properly use numeric range queries in Lucene?

推荐答案

要实现正确的范围查询,您需要使用来自 lucene 的特定定义字段.请参阅 字段 javadoc

To achieve a proper range query you need to use specific defined fields from lucene. See Field javadoc

  • IntPoint:为精确/范围查询索引的 int.
  • LongPoint:长索引用于精确/范围查询.
  • FloatPoint:为精确/范围查询编制索引的浮点数.
  • DoublePoint:精确/范围查询的双索引.

所以您需要确保您添加此查询的字段是这种类型之一.正如您所说,您使用 Neo4j 生成的 lucene 索引.必须有创建此类字段的选项,否则您将无法执行正确的范围查询.

So you need to be sure that your field you add this query is one of this types. As you said you use a Neo4j generated lucene index. There has to be an option to create this kind of fields otherwise you're not able to execute proper range queries.

这篇关于Lucene 查询语言和数值范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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