Range queries in Neo4j using Lucene query syntax

I use Lucene to index nodes in a Neo4j database, and I use Lucene query strings to execute queries. Everything behaves as expected when I execute range queries that are either exclusive or included at both ends:

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

However, this does not seem to work if I indicate that one end of the range request is exceptional and the other is included, for example:

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

I understand that this query can be executed using the QueryContext.numericRange() method, for example:

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

Why can't this be done using Lucene query syntax? I don’t understand the syntax or am I doing the wrong code?

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

+4
source share
2 answers

for the numerical ranges to work, you need to index your data using custom parsers, etc. since lucene did not expect this usecase, see http://wiki.apache.org/lucene-java/SearchNumericalFields and related questions . I think you can do it better in Lucene 3.5, which is part of Neo4j 1.6.GA, although you will have to do some tricks here :)

+1
source

Neo4j 2.3 simple schema index now supports range queries

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

0
source

Source: https://habr.com/ru/post/1393553/


All Articles