Reputation: 633
I'm pretty sure I should see the error I'm making myself. And I'm also sure, I should know how to construct a decent cypher query within java, but I simply can't. It's late and I've been banging my head on this since the last 4 hours. So, I'm giving up.
I have a relatively simply cypher query I want to execute against an open transaction endpoint
http://localhost:7474/db/data/transaction/[# number]
So I figured, I do it just the way I do it when creating a node, but simply match instead of create:
{"statements": [ {"statement": "MATCH (p:POST {properties}) RETURN p", "parameters": {"properties":{"sn_id": "TW", "id": "536627264453353472"}} } ] }
But the server tells me, I cannot use parameter maps in a match like that:
TRACE Neo4JPersistence - sending cypher {"statements": [ {"statement": "MATCH (p:POST {properties}) RETURN p", "parameters": {"properties":{"sn_id": "TW", "id": "536627264453353472"}} } ] } to endpoint http://localhost:7474/db/data/transaction/75
TRACE Neo4JPersistence - GET to http://localhost:7474/db/data/transaction/75 returned status code 200, returned data: {"commit":"http://localhost:7474/db/data/transaction/75/commit","results":[],"transaction":{"expires":"Sun, 23 Nov 2014 21:09:05 +0000"},"errors":[{"code":"Neo.ClientError.Statement.InvalidSyntax","message":"Parameter maps cannot be used in MATCH patterns (use a literal map instead, eg. \"{id: {param}.id}\") (line 1, column 15)\n\"MATCH (p:POST {properties}) RETURN p\"\n ^"}]}
ERROR Neo4JPersistence - ERROR :: [{"message":"Parameter maps cannot be used in MATCH patterns (use a literal map instead, eg. \"{id: {param}.id}\") (line 1, column 15)\n\"MATCH (p:POST {properties}) RETURN p\"\n ^","code":"Neo.ClientError.Statement.InvalidSyntax"}] - could not execute cypher statement at location http://localhost:7474/db/data/transaction/75
So, ok, I thought. Let's go for something simpler, and I constructed my cypher like this:
{"statements": [ {"statement": "MATCH (p:SOCIALNETWORK {"sn_id": "TW"} ) RETURN p"} ] }
But for this, the server returns that it can not deserialize the request and that it does not like the s - whichever s that is.
Here's the stack trace for it:
TRACE Neo4JPersistence - sending cypher {"statements": [ {"statement": "MATCH (p:SOCIALNETWORK {"sn_id": "TW"} ) RETURN p"} ] } to endpoint http://localhost:7474/db/data/transaction/76
TRACE Neo4JPersistence - GET to http://localhost:7474/db/data/transaction/76 returned status code 200, returned data: {"commit":"http://localhost:7474/db/data/transaction/76/commit","results":[],"transaction":{"expires":"Sun, 23 Nov 2014 21:18:01 +0000"},"errors":[{"code":"Neo.ClientError.Request.InvalidFormat","message":"Unable to deserialize request: Unexpected character ('s' (code 115)): was expecting comma to separate OBJECT entries\n at [Source: org.eclipse.jetty.server.HttpConnection$Input@43b86dc2{HttpChannelOverHttp@12dfe4a{r=10,a=DISPATCHED,uri=/db/data/transaction/76},HttpConnection@7291ace0{FILLING},g=HttpGenerator{s=START},p=HttpParser{s=END,87 of 87}}; line: 1, column: 59]"}]}
ERROR Neo4JPersistence - ERROR :: [{"message":"Unable to deserialize request: Unexpected character ('s' (code 115)): was expecting comma to separate OBJECT entries\n at [Source: org.eclipse.jetty.server.HttpConnection$Input@43b86dc2{HttpChannelOverHttp@12dfe4a{r=10,a=DISPATCHED,uri=\/db\/data\/transaction\/76},HttpConnection@7291ace0{FILLING},g=HttpGenerator{s=START},p=HttpParser{s=END,87 of 87}}; line: 1, column: 59]","code":"Neo.ClientError.Request.InvalidFormat"}] - could not execute cypher statement at location http://localhost:7474/db/data/transaction/76
I'm stuck and frustrated by now. Can anyone help me again???
Thanks so much in advance,
Christian
Upvotes: 2
Views: 3064
Reputation: 9255
Since version 2.0.5, you CAN use a property map with MATCH
¥ (and MERGE
):
{
"statements" :
[
{
"statement": "MATCH (p:SOCIALNETWORK {sn_id: {properties}.sn_id)} ) RETURN p",
"parameters": { "properties": {"snid": "TW"} }
}
]
}
Not quite yet as smooth as with CREATE
but still an improvement.
¥ Unfortunately it's officially documented only for MERGE
and not for MATCH
, but tested and used everyday by yours truly
Upvotes: 0
Reputation: 19373
Unlike CREATE, MATCH cannot use a property map- it requires you to use literals. So your query should end up looking like this:
{
"statements" :
[
{
"statement": "MATCH (p:SOCIALNETWORK {sn_id: {snid}} ) RETURN p",
"parameters": {"snid": "TW"}
}
]
}
In your second query, don't put the property key in quotes:
{"statements":
[
{
"statement": "MATCH (p:SOCIALNETWORK {sn_id: 'TW'} ) RETURN p"
}
]
}
Upvotes: 4