I'm trying to create an indexed node in cypher, with the following syntax:
neo4j-sh (?)$ start m=node:person(UID= "1") return m;
==> +------------+
==> | m |
==> +------------+
==> | Node[64]{} |
==> +------------+
==> 1 row
==> 0 ms
==>
neo4j-sh (?)$ start n = node(64) return n.UID;
==> EntityNotFoundException: The property 'UID' does not exist on Node[64]
Why is it that the node appears to be created, but the property I'm creating, and that seems to be successfully returned, does not exist?
Is there an easier way? I used to use py2neo's function:
neo4j.GraphDatabaseService("http://localhost:7474/db/data/").get_or_create_indexed_node(index='person', key='UID', value=self.id, properties={'UID' : self.id})
But this appears to have been deprecated---it no longer works with the latest version of py2neo, which does not appear to support the properties
argument any longer (and for future folks, index
is replaced with index_name
).
An index and a property are two different things.
It seems you have a node in your graph with an index named person
and key/value pair UID:"1". Your first query gets your node by its index. But the index is not a property of the node. You can fire up the webadmin to visualize how the indices are managed in your graph.
As far as i know there is nothing in the documentation on how to create indices with cypher, but you can easily use the REST API to manipulate them (link).