cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Error to create constraint and index on Movie

Today I cannot create named constraint or index. I am getting following error.
Command - CREATE INDEX PersonBornIndex FOR (p:Person) ON (p.born)
Error-
Invalid input 'P': expected whitespace, comment, ON, '=', node labels, MapLiteral, a parameter, a parameter (old syntax), a relationship pattern, ',', FROM GRAPH, CONSTRUCT, LOAD CSV, START, MATCH, UNWIND, MERGE, CREATE UNIQUE, CREATE, SET, DELETE, REMOVE, FOREACH, WITH, CALL, RETURN, UNION, ';' or end of input (line 1, column 14 (offset: 13))
"CREATE INDEX PersonBornIndex FOR (p:Person) ON (p.born)"

4 REPLIES 4

clem
Graph Steward

I think the right syntax is:
CREATE INDEX PersonBornIndex ON :Actor(born)

also this does work:
CREATE INDEX PersonBornIndex IF NOT EXISTS FOR (p:Person) ON (p.born);

Above code is also not working. I am using Sandbox
Error - Invalid input 'P': expected whitespace, comment, ON, '=', node labels, MapLiteral, a parameter, a parameter (old syntax), a relationship pattern, ',', FROM GRAPH, CONSTRUCT, LOAD CSV, START, MATCH, UNWIND, MERGE, CREATE UNIQUE, CREATE, SET, DELETE, REMOVE, FOREACH, WITH, CALL, RETURN, UNION, ';' or end of input (line 1, column 14 (offset: 13))
"CREATE INDEX PersonBornIndex ON :Actor(born)"

Unfortunately, our sandboxes are still using Neo4j 3.5.

You will need to use the 3.5 Cypher syntax:

CREATE INDEX ON :Actor(born)

Index names were introduced in 4.0.

We hope to have 4.0 sandboxes available SOON!

Elaine

Ok, thanks for this information! I would recommend Neo4j to include such information in training documentation to avoid any confusions.