Validate Cypher

You can Validate Cypher against the selected Data Model and against a Neo4j database. To validate:

  • Use the Validate > Validate Cypher Statements menu item

  • Open the Validation panel, and click the Validate button

When validation is run it will:

  • Validate all Cypher statements against the selected Data Model, if a Data Model is selected

  • Validate all Cypher statements againt a Neo4j database, if you are currently connected to a database

Note: due to performance reasons, if your Neo4j database connection is proxied, the database validations will not run.

Data Model Validation

Each Cypher statement is validated against the selected Data Model. The following validations are performed:

  • Match and Optional Match

    • Node Labels

    • Relationship Types

    • Property names within Node Labels conditions

    • Property names within Relationship Types conditions

  • Return

    • Returned properties for the given variable exist on the Node Label associated to that variable

    • Note: to perform the check, the variable must be traceable back to the Match

  • Other

    • Currently keywords such as Where, With, and others are not checked

For each failed validation, an entry will appear under an accordion corresponding to the checked Cypher statement. A green check appears if the Cypher statement is valid.

Database Validation

Ensure you are connected to a Neo4j database. See this link for instructions on how to connect.

Each Cypher statement is inspected to find Match clauses. The Match clauses are parsed and re-written to run them progressively against the database to see if data if found. For instance, given this statement:

MATCH (m:Movie {title: $startMovieTitle})<-[:RATED5]-(:User)-[:RATED5]->(item:Movie)
WITH item, size((item)<-[:RATED5]-()) AS score
RETURN item.title as title, score

The Match would be re-written progressively and each segment run against the database:

MATCH (m:Movie) RETURN * LIMIT 1
MATCH (m:Movie) WHERE exists(m.title) RETURN * LIMIT 1
MATCH (m:Movie)<-[:RATED5]-() RETURN * LIMIT 1
MATCH (m:Movie)<-[:RATED5]-() WHERE exists(m.title) RETURN * LIMIT 1
MATCH (m:Movie)<-[:RATED5]-(:User) RETURN * LIMIT 1
MATCH (m:Movie)<-[:RATED5]-(:User) WHERE exists(m.title) RETURN * LIMIT 1
MATCH (m:Movie)<-[:RATED5]-(:User)-[:RATED5]->() RETURN * LIMIT 1
MATCH (m:Movie)<-[:RATED5]-(:User)-[:RATED5]->() WHERE exists(m.title) RETURN * LIMIT 1

A green check appears if data is found, otherwise an orange triangle appears indicating no data was found. If no data is found it could indicate a mismatch between your Cypher statment and the data loaded in the database, or it could indicate that data has not been loaded in your database yet.