0
votes

Suppose i have graph where each user has label 'user' and property 'name' According to Neo4j 2.0 documentation we can create index using following cypher command

CREATE INDEX ON :user(name);

However if write a Cypher query using START clause like:

start n=node:user(name='john') return n

Then i am getting the following error

MissingIndexException: Index `user` does not exist

My question is how can i define the name of index in first place. I know that in Neo4j 2.0 using start clause is optional. However if i need to use them what is the best way to proceed

1

1 Answers

3
votes

You are mixing the concepts of legacy indexes and the new 2.0 label-based indexes. Instead of using the START clause, use the MATCH clause, like so:

MATCH (n:user)
WHERE n.name='john' // this causes an index lookup
RETURN n

Also note that Cypher style usually uses initial case names for labels, like :User. Labels are case-sensitive.