Reputation: 311
Trying out the latest Neo4j 2.0 M01. I also Downloaded the full cinecast graph.db and configured it to work with 2.0 store according to the great video tutorial by Michael, see here: http://vimeo.com/63707662
I would like to get familiar with labels so my idea was to add some labels to some nodes being index as User,Person.
start n=node:Person("id:") set n:Humans return count ();
That worked, it added labels to all nodes being indexed (but i cant see it visually in the web console..but anyway it is there when query for it)
However this doesn't work:
neo4j-sh (0)$ start n=node:Person("id:*") match n where ID(n)>700 and ID(n)<710 set n:Journalist return n;
ResourceAcquisitionFailedException: The transaction is marked for rollback only
Two problems: is there today any typecast function string to int? The ID(n) was the only thing i could come up with to update partial nodes of the index since id,names etc are strings.
And secondly why doesnt it set a Journalist label onto the node group above? http://docs.neo4j.org/chunked/2.0.0-M01/query-set.html#set-set-a-label-on-a-node
Als,Can Labels be multiple word like:
start a=node(1,2,3,4)
match a
where a.name='Anders'
set a:helicopter pilot
return a
Error: expected valid query body "set a:helicopter pilot "
And finally, in the Neo4j api docs when trying out the queries there is something with the node(0) root that doesn't work, following is a valid query right (at least useful)?
start a=node(*)
match a
where a.name='Anders'
return a
Error: org.neo4j.cypher.EntityNotFoundException: The property 'name' does not exist on Node[0]
Thank you!
Upvotes: 2
Views: 2717
Reputation: 41676
Great that you try it out. Your feedback is very appreciated.
START n=node:Person("id:*")
MATCH n where ID(n)>700 and ID(n)<710
SET n:Journalist
RETURN n; //or count(*)
ResourceAcquisitionFailedException: The transaction is marked for rollback only
That error shouldn't happen.
btw. in that query you don't need MATCH
.
you can update partial sets of nodes with WITH
and LIMIT
/ SKIP
START n=node:Person("id:*")
WITH n
// optional ORDER BY n.name
SKIP 700 LIMIT 10
SET n:Journalist
RETURN n;
Currently there is only implicit typecasting afaik, e.g. when adding strings and numbers.
The Journalist label wasn't set b/c of the failed transaction.
Labels can be multiple words, if you quote them with backticks.
start a=node(1,2,3,4)
where a.name='Anders'
set a:`helicopter pilot`
return a
Again you don't need MATCH
in this query.
If there is a node which doesn't have a name property you have to check if it is there before, e.g. with
has(a.name) and a.name='Anders'
there are two shortcuts, one that returns true if the property is not there (property optional)
a.name? ='Anders'
and one that returns false when the props is not there (property required)
a.name! ='Anders'
start a=node(*)
match a
where a.name?='Anders'
return a
Upvotes: 4