Note: I have also asked this question in stackoverflow, but I want a *second
opinion*. Post is
here:
http://stackoverflow.com/questions/29353718/cypher-indexing-common-property-on-all-nodes/
As per new indexing rules, the auto_index will go away in future and its
expected to create indexes using cypher. According to this new way, to
index a node property, you MUST provide a Node Label.
*I have a 'nodeId' property present on all types of Node Labels - User,
Employee, Bank, Car, etc.*I used to auto-index this property to retrieve
any type of node if its nodeId is known. Please note that since auto-index
did not require me to give a Node Label, it was possible for me to do what
I did.
ReadableIndex<Node> readableIndex =
this.graphDatabaseService.index().getNodeAutoIndexer().getAutoIndex();
readableIndex.get("nodeId", "0").getSingle();
But with new style, I have to create index on nodeId property for each and
every Node Label. So I have to do this:
create index on :User(nodeId)
create index on :Employee(nodeId)...
Moreover, my method getByNodeId(String nodeId) is useless now because this
cypher query IMHO will not be able to use the index anymore since I am not
passing any node label.
match (node) where node.nodeId = {nodeId} return node;
Since the whole point of my getByNodeId() method was to be generic across
all nodes, I cannot give this cypher query a node label. So what should I
do here. My 2 questions are:
- How do I tell neo4j via cypher to index on all node labels
- How do I write a cypher query which uses index not based on node
label, but based on node property.
*Note:*
-
It is essential for me to use cypher because I am using neo4j-jdbc and
they have no method to create auto-index or access the auto-indexer
(atleast not that I know of).
-
Some might suggest me to change the neo4j.properties to enable
auto-indexing there, but I dont like changing configuration files. I want
to do it in my program. Anyway, that would have only solved the first
issue. Second issue is still there.
--
You received this message because you are subscribed to the Google Groups
"Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.