How to update Nodes within a random manner in Neo4j -
how can update random set of nodes in neo4j. tried folowing:
match (firstgraph) id(firstgraph) id return firstgraph.name, firstgraph.version,id(firstgraph) order rand(); match (g1:firstgraph) id(g1)=id set g1.version=5
my idea random set update it, got error:
expected 1 statement per query got: 2
thanks help.
let's find out what's problem here, first of all, error
expected 1 statement per query got: 2
this coming query, if check it, see did 2 queries in same sentence, that's why error.
match (firstgraph) id(firstgraph) id return firstgraph.name, firstgraph.version,id(firstgraph) order rand(); match (g1:firstgraph) id(g1)=id set g1.version=5
this not query, because can't use ;
in query sentence, it's query end marker, can't query after this, can use union
:
match (firstgraph) id(firstgraph) id return firstgraph.name, firstgraph.version,id(firstgraph) order rand() union match (g1:firstgraph) id(g1)=id set g1.version=5
also, if want match random set of nodes, can (this example 50% chances each node):
match (node) rand() > 0.5 return node
and whatever want node using with
Comments
Post a Comment