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

查看:451
本文介绍了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天全站免登陆