Range queries in Neo4j using Lucene query syntax

我怕爱的太早我们不能终老 提交于 2019-12-10 15:28:10

问题


I'm using Lucene to index nodes in a Neo4j database and I'm using Lucene query strings to perform queries. Everything behaves as expected when I perform range queries that are either exclusive or inclusive on both ends:

Index.query("value:[1 TO 10]");  // Inclusive range query
Index.query("value:{1 TO 10}");  // Exclusive range query

However, it doesn't seem to work if I specify one end of the range query to be exclusive and the other to be inclusive, for example:

Index.query("value:[1 TO 10}");

I understand that it is possible to perform this query using the QueryContext.numericRange() method, for example:

Index.query(QueryContext.numericRange("value", 1, 10, true, false));

Why is it not possible to do the same using Lucene query syntax? Am I misunderstanding the syntax or doing something incorrectly code-wise?

References:
http://docs.neo4j.org/chunked/stable/indexing-lucene-extras.html
http://lucene.apache.org/java/3_5_0/queryparsersyntax.html


回答1:


in order for numeric ranges to work, you have to index your data with custom parsers etc, since lucene did not anticipate this usecase, see http://wiki.apache.org/lucene-java/SearchNumericalFields and the related issues. I think you can do it better in Lucene 3.5 which is part of Neo4j 1.6.GA though, but you will have to pull some tricks here :)




回答2:


Plain schema index in Neo4j 2.3 now supports range queries

http://neo4j.com/release-notes/neo4j-2-3-0/



来源:https://stackoverflow.com/questions/9049029/range-queries-in-neo4j-using-lucene-query-syntax

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!