title: Neo4j: Cypher query to parallelize a row of the result from a previous query
body: <p>I have a database where sentences are related to each other. I have to perform a big update on the whole database, thus I'm trying to parallelize the update.</p>
  <p>The relevant cypher query looks like this:</p>
  <pre><code>match (s:Sentence)-[r:RELATED]-(t:Sentence)
  return s as sentence, collect(t.embedding) as neighbours_embeddings
  </code></pre>
  <p><code>embedding</code> is a list of numbers.</p>
  <p>This returns a result like this:</p>
  <pre><code>---------------------------------------
  | sentence   |  neighbours_embeddings |
  ---------------------------------------
  | sentence1  | [[1, 2, 3], [4, 5, 6]] | 
  ---------------------------------------
  | sentence2  | [[2, 3, 5]]            |
  ---------------------------------------
  </code></pre>
  <p>Now I wanna perform some operations on the neighbours_embeddings and set a property in the corresponding Sentence node.</p>
  <p>I've looked at different parallelization techniques in Neo4j and as far as I understood, all of them need a list as input. But my input would be a tuple like (sentence, neighbours_embeddings). How do I achieve this?</p>
  <p>Full query for interested folks:</p>
  <pre><code>match (s:Sentence)-[r:RELATED]-(t:Sentence)
  with s as sentence, collect(t.embedding) as neighbours
  with sentence, [
      w in reduce(s=[], neighbour IN neighbours | 
      case when size(s) = 0 then
      neighbour else [
          i in range(0, size(s)-1) |
          s[i] + neighbour[i]] end) |
          w / tofloat(size(neighbours))
      ] as average
   
   with sentence, [
       i in range(0, size(sentence.embedding)-1) |
       (0.8 * sentence.embedding[i]) + (0.2 *average[i])
   ] as unnormalized
   
   with sentence, unnormalized, sqrt(reduce(sum = 0.0, element in unnormalized | sum + element^2)) as divideby
   set sentence.normalized = [
       i in range(0, size(unnormalized)-1) | (unnormalized[i] / divideby)
   ]
  
  </code></pre>