Neo4j manual/explicit indexes and non-string range

2019-08-15 05:51发布

I was able to port my Neo4j 3.4.0 application to use manual indexes and APOC procedures instead of queries over the indexles relationship properties. Everything is working like a charm except one last thing - I ran into the issue with non-string Lucene range queries.

They are not working as expected Lucene query language and numeric range

For example:

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

that is obviously not the something that was expected.

Is there anything in Neo4j/APOC that I can do in order to get it working properly?

1条回答
祖国的老花朵
2楼-- · 2019-08-15 06:22

If you read the docs, it says

'Sorting is done lexicographically'

See 'Range queries' under: https://lucene.apache.org/core/6_4_1/queryparser/org/apache/lucene/queryparser/classic/package-summary.html

You should index the data into, for example a DoubleDocValuesField instead of a StringField/TextField and use a appropriate Lucene query, like PointRangeQuery

查看更多
登录 后发表回答