cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Problem with escaping a char in a json in a MERGE statement

Hello,

I have a problem with a char in a JSON - the following request (in the Neo4j Browser):

CALL apoc.es.get('localhost','BEAT','_search',null,null,'{"size":1,"query":{"range":{"@timestamp":{ "gte":"2019-11-18T00:00:00.000Z","lt":"2019-11-22T22:30:00.000Z"}}}}') 
yield value with value.hits.hits as hits
UNWIND hits as hit
RETURN hit

responds the following:

{
...
   "@timestamp": "2019-11-18T18:55:27.186Z", 
...
    "_id": "pAbef24B7Iy8Ibw1p4GW",
    
...
}

The timestamp object contains a @ and I tried to escape the @ in a merge statement with:

MERGE (event:event {
id: hit._id, 
time: hit.\@timestamp}

it occurs with:

Invalid input '\': expected an identifier, whitespace, a function name or a property key name

I also tried other ways to escape:

hit.\\@timestamp 
hit.\u0040timestamp >>> utf 16: @ > 0040
"hit.\@timestamp" >>> double ticks MERGE all nodes with the string 

How could I escape the @ in a json object in MERGE statement?
Is there an escape hierarchy between cypher and the under lying parser?

Greetings Sebastian

(Btw.: The @ comes from the elastic search common scheme.)

1 REPLY 1

Just use backticks.

MERGE (event:event {
id: hit._id, 
time: hit.`@timestamp`}