The USE Cypher statement was introduced in Neo4j 4.0 to tell Cypher which shard to use. For instance, we can add some data to one of our databases with the following query:
USE fabric.gr1
CREATE (c:Country {name: "USA"})
CREATE (u1:User {name: "u1"})
CREATE (u2:User {name: "u2"})
CREATE (u1)-[:LIVES_IN]->(c)
CREATE (u2)-[:LIVES_IN]->(c)
CREATE (o1:Order {name: "o1"})
CREATE (o2:Order {name: "o2"})
CREATE (o3:Order {name: "o3"})
CREATE (u1)-[:ORDERED]->(o1)
CREATE (u2)-[:ORDERED]->(o2)
CREATE (u2)-[:ORDERED]->(o3)
We can retrieve data from this shard using the following code:
USE fabric.gr1
MATCH (order:Order)<--(:User)-->(country:Country) RETURN "gr1" as db, country.name, count(*) AS nbOrders
The preceding query will use only nodes in the gr1 database, as defined in the fabric configuration section in neo4j.conf. You can run the same query with USE fabric.gr2 ...