bin/neo4j-shell allows for a command line interface to query your graph via Cypher statements and to include parameters to those statements. Usage of parameters, rather than hard coding values, will allow for re-use of the query plan cache.

A parameter can be defined within neo4j-shell via the export command, for example:

neo4j-sh (?)$ export p1="Nora Ephron"

Multi-word values for parameters should be enclosed in double quotes.
Parameters can be displayed within neo4j-shell via the env command, for example:

neo4j-sh (?)$ export p1="Nora Ephron"
neo4j-sh (?)$ env
TITLE_MAX_LENGTH=40
p1=Nora Ephron
TITLE_KEYS=.*name.*,.*title.*

Once a parameter is defined, it can be used in a Cypher statement, for example:

neo4j-sh (?)$ export p1="Nora Ephron"
neo4j-sh (?)$ env
TITLE_MAX_LENGTH=40
p1=Nora Ephron
TITLE_KEYS=.*name.*,.*title.*
neo4j-sh (?)$ match (n:Person {name:'Tom Hanks'})-[:ACTED_IN]->(n1:Movie)<-[:DIRECTED]-(n2:Person {name:{p1}}) return n1.title;
  • Last Modified: 2018-10-16 18:11:27 UTC by Dana Canzano.
  • Relevant for Neo4j Versions: 2.2, 2.3, 3.0.
  • Relevant keywords parameters, neo4j-shell, quotes.

Details


Author:
Dana Canzano
Applicable versions:
2.2, 2.3, 3.0
Keywords:
neo4j-2.2neo4j-2.3neo4j-3.0neo4j-shellparametersquotes