properties in a cypher query

39 views
Skip to first unread message

Cato Nano

unread,
Jul 31, 2014, 12:21:43 AM7/31/14
to clojur...@googlegroups.com
I have this cypher query

MERGE (linea:Line {name:295})

How do I deal with curly braces ?

(cy/tquery connection "MERGE (linea:Line {name:{line-id}})" {:line-id my-id})

Some couples of curly braces belong to the cypher syntax, some others don't. Won't tquery be confused ?

Michael Klishin

unread,
Jul 31, 2014, 12:28:30 AM7/31/14
to clojur...@googlegroups.com, Cato Nano
 On 31 July 2014 at 08:21:43, Cato Nano (cato...@gmail.com) wrote:
> > (cy/tquery connection "MERGE (linea:Line {name:{line-id}})"
> {:line-id my-id})
>
> Some couples of curly braces belong to the cypher syntax, some
> others don't. Won't tquery be confused ?

tquery does not interpret Cypher, it sends things as they are to Neo4J
(query parameters are converted to JSON, of course).

So there should be nothing Neocons-specific for MERGE queries.
--
@michaelklishin, github.com/michaelklishin

Catonano

unread,
Jul 31, 2014, 1:01:24 AM7/31/14
to clojur...@googlegroups.com
And how would you write a Cypher query with a node property expressed in a query parameter ?

I tried both


(cy/tquery connection "MERGE (linea:Line {name:{line-id}})" {:line-id my-id})

and


(cy/tquery connection "MERGE (linea:Line {name:line-id})" {:line-id my-id})


and they both didn't work

Michael Klishin

unread,
Jul 31, 2014, 1:05:54 AM7/31/14
to clojur...@googlegroups.com, Catonano
On 31 July 2014 at 09:01:24, Catonano (cato...@gmail.com) wrote:
> > And how would you write a Cypher query with a node property expressed
> in a query parameter ?
>
> I tried both
>
> (cy/tquery connection "MERGE (linea:Line {name:{line-id}})"
> {:line-id my-id})
>
> and
>
> (cy/tquery connection "MERGE (linea:Line {name:line-id})"
> {:line-id my-id})

I suspect you want to use a map of properties (props in CREATE (n:Person { props }) ) with operators like MERGE:
http://docs.neo4j.org/chunked/stable/rest-api-cypher.html#rest-api-create-a-node-with-multiple-properties
--
@michaelklishin, github.com/michaelklishin

Catonano

unread,
Jul 31, 2014, 1:23:10 AM7/31/14
to Michael Klishin, clojur...@googlegroups.com
No, I wanted to use one property only, no need for a map.

The answer was

 (cy/tquery connection "MERGE (linea:Line {name: {lineid}}) RETURN linea" {:lineid 10})
 
with "lineid" instead of "line-id", that is, with no - (dash)

that was all

Well, it worked. Thanks !

Michael Hunger

unread,
Jul 31, 2014, 6:21:28 AM7/31/14
to clojur...@googlegroups.com
As you had special characters (dash) in there, you have to backtick them for escaping.


--
Documentation: http://clojureneo4j.info
Issues: https://github.com/michaelklishin/neocons/issues
 
More Clojure libraries: http://clojurewerkz.org
---
You received this message because you are subscribed to the Google Groups "clojure-neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure-neo4...@googlegroups.com.
Visit this group at http://groups.google.com/group/clojure-neo4j.
For more options, visit https://groups.google.com/d/optout.

Catonano

unread,
Aug 1, 2014, 12:34:39 AM8/1/14
to clojur...@googlegroups.com
2014-07-31 12:21 GMT+02:00 Michael Hunger <michael...@neotechnology.com>:
As you had special characters (dash) in there, you have to backtick them for escaping.

I can see that now. Thank you, Michael
Reply all
Reply to author
Forward
0 new messages