Neo4j server plugin basic questions -
Neo4j server plugin basic questions -
i using neo4j v2.1.5 , creating server plugin.
how create unique node i.e. guarantee uniqueness of property? is there hook in plugin lifecycle, constraints , indexes can created? returning node returns finish database. how can homecoming node or pojo list json? there working examples or explanation of representation available?i using java api , not cypher.
how create unique node i.e. guarantee uniqueness of property?
you can create unique constraint on (label, property) pair ensure uniqueness of property.
e.g.
create unique constraint on :person(name)
would ensure can't have 2 people nodes same name. if want java api you'd like this:
try ( transaction tx = graphdb.begintx() ) { graphdb.schema() .constraintfor( dynamiclabel.label( "person" ) ) .assertpropertyisunique( "name" ) .create(); tx.success(); }
is there hook in plugin lifecycle, constraints , indexes can created?
you can in transaction iirc can create 1 index/constraint per transaction.
returning node returns finish database. how can homecoming node or pojo list? there working examples or explanation of representation available?
do mean cypher? simple query homecoming 1 node this:
match (n) homecoming n limit 1
in cypher land homecoming map of properties node has on it. if want more specific seek this:
match (n:person) homecoming n.name personname limit 1
so you'd string column in result set.
-- updating java api --
from java api can write own traversals give 'node' , 'relationship' objects. you'd have extract properties you're interested in.
try ( transaction tx = graphdatabaseservice.begintx() ) { resourceiterable<node> people = globalgraphoperations.at( graphdatabaseservice ).getallnodeswithlabel( dynamiclabel.label( "person" ) ); ( node node : people ) { string name = (string) node.getproperty( "name" ); } tx.success(); }
neo4j
Comments
Post a Comment