Query with multiline string not interpreted by neo4j browser

Hi there, I'm currently trying to run a multi-line query through an apoc's iterate function (targetting 70M nodes hence the need).

I encounter a weird situation when trying to launch the query from the browser, it seems that the multi-line induces a bad interpretation of the script.

Here is the code I'm trying to run, and below that is the rendering of the browser :

CALL apoc.periodic.iterate(
"MATCH (p:RABBIT)",
"SET p.mail = REDUCE(s = '', c IN split(p.mail,'') |
	s + CASE c
      WHEN '-' THEN '@'
      ELSE c
    END
)", {batchSize:100, iterateList:true, parallel:true})

wrong query interpretation

The upcomming error, if one needed to see it ... No surprise in it since the parenthesis is not well interpreted.

Has anyone already encountered this situation ? Or could one try to reproduce it ?
A similar issue seems to have been raised here : Multi Line String are not colored ยท Issue #924 ยท neo4j/neo4j-browser ยท GitHub, but according to the OP it didn't affect the final result, more like a visual glitch.

Thanks in advance,

Yes I have seen this before. You can have a multi-line cypher but you cannot have a multi-line string value unless you use + to concatenate them. Here's an example:

CALL apoc.periodic.iterate(
"MATCH (t:Test) return t",
"SET " +
"t.type=1", {batchSize:100, iterateList:true, parallel:true})

I personally just keep the whole string in one line.

Alright kinda disapointing, even more since I actually have more than 20 lines of conditions in my CASE querystring. But thanks for the reply :smiley:

I hope this little issue gets fixed in the future.

EDIT: Reason found ! It was actually a mistake on my side in the 1st inner argument of the apoc function, I forgot to RETURN the variable p onto wich works the 2nd argument.

CONCLUSION : There is indeed a graphic bug, but it doesn't affect the overall query processing !

1 Like

Anyone know if there is an update on this? Hoping that a solution like "start the query with three double quotes and end the query with three double quotes" (or something similar to that) might eventually get implemented to allow for breaking the query into multiple lines, so that you don't have to use a plus sign to concatenate them (and add a space where necessary to some of the lines).

The original post had a problem with the query:

CALL apoc.periodic.iterate(
"MATCH (p:RABBIT)",              // <-- not the right query structure
"SET p.mail = REDUCE(s = '', c IN split(p.mail,'') |
	s + CASE c
      WHEN '-' THEN '@'
      ELSE c
    END
)", {batchSize:100, iterateList:true, parallel:true})

you can see the example from the documentation:

CALL apoc.periodic.iterate(
  "MATCH (p:Person) WHERE (p)-[:ACTED_IN]->() RETURN p",        // <-- has a return
  "SET p:Actor",
  {batchSize:10000, parallel:true})