This is all fine, but I now have a problem of going the other way, i.e. starting with an array of all the record_ids from a graph such as the one above and needing to fill in all the paths.
The reason for this is that elsewhere in my application users are performing a variety of searches incrementally and merging the results together. The records they end up with will most likely have some links between them and they want to see them displayed as a graph.
Hi - I see you have not gotten a reply so I can see if I can ask an internal team for some insight.
You’ve already mentioned using apoc.path.expand, so we know APOC is in play. With the details below, I'll know whether this is best handled by the APOC team, Cypher team, GDS, or Support and see what I can do.
Which Neo4j edition are you running? (Community, Enterprise, or Aura)
What Neo4j version are you on? (e.g., 5.20, 4.4 LTS)
About how big is your dataset? (dozens, thousands, or millions of nodes/relationships)
Where are you running this query? (Neo4j Browser, Cypher Shell, or through an application/integration like Spring, GraphQL, Python, etc.)
Thanks for getting back to me. The answers are as follows:
Community.
Various versions, e.g. 2025.02.0 and 2025.09.0 depending on the system.
Thousands.
I’m making calls to the http interface of a Neo4j server.
This is part of a larger application where the data are stored in PostgreSQL, but some parts are copied into Elasticsearch and Neo4j for specific searching needs. The example APOC graph I gave above, for example, is for a part of the application where users plot a graph of relationships between our records from a given starting point.
The problem here is that users will get their record_ids of interest by performing other searches, e.g. via Elasticsearch, and will want to come back to Neo4j to plot a graph of what they’ve found.
Hi if you want to see all records with record_id in $record_ids, you can try: MATCH (n:Record) WHERE n.record_id IN $record_ids OPTIONAL MATCH (n)-[r]->(m) WHERE m.record_id IN $record_ids RETURN n, r, m