简体   繁体   中英

Neo4j REST Cypher and params: what can be a parameter in a Cypher query through REST

I was trying the make this query work using params with no luck. I was always getting the same error.

expected either node or relationship here
"start n={start} match n-[r:{rel}]-() return n, n.name, r, r.since"
         ^

Then, I removed the {start} param and I used a backtip (`) for the relationship and it worked like a charm.

start n=node(*) match n-[r:`{rel}`]-() return n, n.name, r, r.since

So, what's the proper way to use params and where can I use them in a query?

Just in case, backtip the {start} doesn't work either. The next request doesn't work either.

POST /db/data/cypher {"query": "start n=node({start}) match n-[r:`{rel}`]-() return n, n.name, r, r.since", "params": {"start": "*", "rel": "l353456"}}

I'm using 1.9M01

Backticking start (because start is a keyword) would look like this

POST /db/data/cypher {"query" : "start n=node({`start`}) return n", "params": {"start":0}}

Tested on the Neo4j Http console.

Javier, http://docs.neo4j.org/chunked/snapshot/cypher-parameters.html lists the patterns, so in your case I think

start n=({start}) match n-[r:XXX]-() return n, n.name, r, r.since

is what you can do. relationship types are considered as changing the structure of your query, and thus not parameterizable. You will have to re-submit the query or concatenate the query in your client code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM