2

我想知道是否有任何方法可以使用自动索引进行范围查找。如果我查询类似

START age=node:node_auto_index(age<20 and age>10) RETURN age;

它返回

Exception in thread "main" string literal or parameter expected.

我也尝试过类似的东西

START age=node:node_auto_index(age = range(10,20)) 
RETURN age;

但看起来它只需要age = "15"或类似的东西。

有什么想法吗?

4

3 回答 3

3

Lucene 文档指出范围语法如下:

age:[10 TO 20]

结果查询(但尚未对此进行测试):

START age=node:node_auto_index("age:[10 TO 20]") 
RETURN age;

以下阅读内容可能对您来说也很有趣:Neo4j 中使用 Lucene 查询语法的范围查询

编辑:不确定它是否适合你;看看这个github 问题

于 2013-05-02T07:24:34.103 回答
0

为什么不使用 where 子句,如下所示?

START node=node:node_auto_index(name='PersonName') 
where node.age > 20 and node.age <20
RETURN node.age;
于 2013-05-02T06:43:27.347 回答
0

在与来自 Neo4J Technologies 的 Stefan Armbruster 的研讨会之后,出现了相同的主题。

我们提出的最基本的解决方案是确保为数字属性存储的所有值具有相同的长度。因此,需要按如下方式填充年龄属性值,011、099、103... 并且这些值存储为字符串而不是数值。

这样做一切都应该从索引开始。

于 2014-09-19T11:46:07.263 回答