neo4j - create unique node or create unique index -
how create unique node in neo4j
? have model user, , has property userid
, sername
, emailid
, mobile
, address
, zipcode
ect...
i want create unique node above user. have userid
, username
, emailid
, mobile
unique field. so, when same userid
or field mention here trying enter again, should return error.
it possible?
i'm assuming stable version of neo4j(1.9) 2.0 change how indexing presented.
you're saying user
node have several properties, each unique, these used composite key, or username used key?
neo4j has special class doing type of "get or create" node, works on 1 key, if creating composite key, you'd have concatenate yours keys.
look documentation here. here example:
public node getorcreateuserwithuniquefactory(string username, graphdatabaseservice graphdb) { uniquefactory<node> factory = new uniquefactory.uniquenodefactory(graphdb, "users") { @override protected void initialize(node creatednode, map<string, object> properties) { created.setproperty("username", properties.get("username")); } }; return factory.getorcreate("username", username); }
Comments
Post a Comment