Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
12-09-2021 05:13 AM
I'd like to filter some of the nodes (or relationships) from the meta graph.
If I just call apoc.meta.graph()
, the resulting nodes (and relationships) seem to have properties:
"nodes": [
{
"identity": -1826,
"labels": [
"A"
],
"properties": {
"name": "A",
"count": 21
}
}
...
]
However, the following query fails to select the nodes without name "A", but results in no nodes at all.
call apoc.meta.graph()
yield nodes, relationships
with [x in nodes | x.name <> "A"] as nodes, relationships
return nodes, relationships
I also tried x.properties.name
or x["properties]["name"]
, but all result in no nodes at all. So it seems that these virtual nodes don't seem to have any properties.
Any ideas on how to properly filter nodes (or relationships) from the meta graph?
Thx, Koen
Solved! Go to Solution.
12-09-2021 07:22 AM
@koen.smets
The apoc.meta.graph
returns a virtual graph, therefore the "classic" neo4j methods don't work.
You have to use the apoc.any.properties
or the apoc.any.property
.
See here: apoc.any - APOC Documentation
For example:
call apoc.meta.graph()
yield nodes, relationships
with [x in nodes where apoc.any.properties(x).name <> "A"] as nodes, relationships
return nodes, relationships
or, filtering both nodes and rels:
call apoc.meta.graph()
yield nodes, relationships
with [x in nodes where apoc.any.property(x, 'name') <> "A"] as nodes, [x in relationships where apoc.any.property(x, 'type') <> "E"] as relationships
return nodes, relationships
12-09-2021 07:22 AM
@koen.smets
The apoc.meta.graph
returns a virtual graph, therefore the "classic" neo4j methods don't work.
You have to use the apoc.any.properties
or the apoc.any.property
.
See here: apoc.any - APOC Documentation
For example:
call apoc.meta.graph()
yield nodes, relationships
with [x in nodes where apoc.any.properties(x).name <> "A"] as nodes, relationships
return nodes, relationships
or, filtering both nodes and rels:
call apoc.meta.graph()
yield nodes, relationships
with [x in nodes where apoc.any.property(x, 'name') <> "A"] as nodes, [x in relationships where apoc.any.property(x, 'type') <> "E"] as relationships
return nodes, relationships
All the sessions of the conference are now available online