Neo4j and Cypher - How can I create/merge chained sequential node relationships (and even better time-series)?
<p>To keep things simple, as part of the ETL on my time-series data, I added a sequence number property to each row corresponding to 0..370365 (370,366 nodes, 5,555,490 properties - not that big).  I later added a second property and named it "outeseq" (original) and "ineseq" (second) to see if an outright equivalence to base the relationship on might speed things up a bit.</p>

<p>I can get both of the following queries to run properly on up to ~30k nodes (LIMIT 30000) but past that, its just an endless wait. My JVM has 16g max (if it can even use it on a windows box):</p>

<pre><code>MATCH (a:BOOK),(b:BOOK)
WHERE a.outeseq=b.outeseq-1
MERGE (a)-[s:FORWARD_SEQ]-&gt;(b)
RETURN s;
</code></pre>

<p>or</p>

<pre><code>MATCH (a:BOOK),(b:BOOK)
WHERE a.outeseq=b.ineseq
MERGE (a)-[s:FORWARD_SEQ]-&gt;(b)
RETURN s;
</code></pre>

<p>I also added these in hopes of speeding things up:</p>

<pre><code>CREATE CONSTRAINT ON (a:BOOK)
ASSERT a.outeseq IS UNIQUE

CREATE CONSTRAINT ON (b:BOOK)
ASSERT b.ineseq IS UNIQUE
</code></pre>

<p>I can't get the relationships created for the entire data set!  Help!</p>

<p>Alternatively, I can also get bits of the relationships built with parameters, but haven't figured out how to parameterize the sequence over all of the node-to-node sequential relationships, at least not in a semantically general enough way to do this.</p>

<p>I profiled the query, but did't see any reason for it to "blow-up".</p>

<p>Another question:  I would like each relationship to have a property to represent the difference in the time-stamps of each node or delta-t.  Is there a way to take the difference between the two values in two sequential nodes, and assign it to the relationship?....for all of the relationships at the same time?</p>

<p>The last Q, if you have the time - I'd really like to use the raw data and just chain the directed relationships from one nodes'stamp to the next nearest node with the minimum delta, but didn't run right at this for fear that it cause scanning of all the nodes in order to build each relationship.   </p>

<p>Before anyone suggests that I look to KDB or other db's for time series, let me say I have a very specific reason to want to use a DAG representation.</p>

<p>It seems like this should be so easy...it probably is and I'm blind.  Thanks!</p>