Note that there are some explanatory texts on larger screens.

plurals
  1. PONumeric comparison operators and wildcards in Gremlin
    text
    copied!<p>Is there a way to search a manual index in Neo4j using a numeric comparison operator(>=, &lt;=, &lt;, >, ...)? Looking at the Gremlin index examples, they all tend to present a search with a specific property value.</p> <p>Say I have around 10M relationships of two types which both have numeric value in a property called 'property', in the first double, in the second int.</p> <pre><code>gremlin&gt; g.e(123).getProperty('property') ==&gt; 1.57479276459179 </code></pre> <p>Now, if I knew the exact property value, which is a log-based pvalue of type double, I could easily locate the node with</p> <pre><code>gremlin&gt; g.idx('index_e_ASSOC').get('property', 1.57479276459179) ==&gt; e[2421730][31493-ASSOCIATION-&gt;53378] ==&gt; e[4885094][53378-ASSOCIATION-&gt;31493] ==&gt; e[866409][37891-ASSOCIATION-&gt;6292] ==&gt; e[123][6292-ASSOCIATION-&gt;37891] </code></pre> <p>Instead I want to do a range search for the 'property', so for example find all edges in which 'property' >= 0 &amp;&amp; 'property' &lt;= 1.6. Is this something that could be done with Gremlin? Looking at <a href="https://groups.google.com/forum/#!msg/gremlin-users/9B8FJlV8n1o/Rn33V03-Z6MJ" rel="nofollow">Gremlin users discussion group</a> tells me that even the wildcard search from a fulltext Lucene index is a bit of hack, and <a href="http://tinkerpop.com/maven2/com/tinkerpop/blueprints/0.5/api/com/tinkerpop/blueprints/pgm/impls/neo4j/Neo4jIndex.html" rel="nofollow">Neo4j API</a> doesn't help.</p> <p>Edit: Found another question like this in Stackoverflow (titled "Range queries in Neo4j using Lucene query syntax"; new users can only post a maximum of two hyperlinks) which lead to Neo4j documentation. I recreated the index by using ValueContext for numeric values. By following an example found in neo4j discussion group (title: combine numericRange query with relationship query) I can do a query like</p> <pre><code>start a=node(123) match a-[rel]-(b) where type(rel) = "ASSOCIATION" AND rel.`property` &gt; 1.0 AND rel.`property` &lt; 2.0 RETURN b LIMIT 20; </code></pre> <p>which uses the range search. What's the syntax for Gremlin? It should be something like</p> <pre><code>g.idx('index_e_ASSOC')[[property: Neo4jTokens.QUERY_HEADER + "[1.0 TO 2.0]"]].count() </code></pre> <p>Which is syntactically correct, but count yields 0 results even though there are edges with property within that range.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload