Reputation: 425
Apologies if this seems somewhat open ended. With the Doctrine based PHP wrapper for Neo4j from Github, how does one define an index on specific properties and nodes? For instance, if I create a node with a property of "fullName" => "Bob Marley"
, how could I define a unique index for that and other nodes I create with the same "User"
entity class so instead of an index of "Entity\User"
assigned to each node, I have unique indexes for each which will be the value of the "fullName"
property e.g. "Bob Marley"
, "Niel Young"
?
The reasoning behind this is there will be 1,000s of nodes and I'd prefer searching by a unique index rather by the same index for all users, then cyphering by fullName, it just seems like an extra step that can be eliminated by defining unique indexes for each node, or am I mistaken? Thanks in advance.
Upvotes: 1
Views: 397
Reputation: 526
If you look into the latest version of neo4j 2.0. They have introduced a new way of indexing. Which is label based indexing. Basically you can set up an index on a particular property of a node for a specified label. This way you will have separate indexes for nodes with different different labels. indexing in neo4j 2.0 with cypher
In the same way you can add constraints on a property under a specified label. Currently only uniqueness constraint is supported. constraints in neo4j 2.0 with cypher
I have not used Neo4j-PHP-OGM
so cannot point out the exact functions, but you can directly run the cypher queries. OR use the REST API for them.
indexing in neo4j 2.0 with REST
constraints in neo4j 2.0 with REST
Upvotes: 1