Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
12-30-2021 07:03 AM
I have a node containing these property names: "name"
, "A"
, "B"
, "C"
, ..., "ZA"
, "ZB"
, "ZC"
,...
(That is, using the query match (x) where x.name="a" return keys(x)
will return the result ["name", "A", "B", "C", ..., "ZA", "ZB", "ZC", ...]
).
I want to return all properties whose names start with "Z"
match (x) where x.name="a" return x.ZA, x.ZB, x.ZC, ...
But since each node has a different number of Z*
properties, I need a way to not specify the properties when returning.
Is there a way to do so? I read the manual for WHERE
, RETURN
and Filtering Query Results but there is nothing useful.
(This question is also asked on Stack Overflow)
12-31-2021 11:33 AM
Hi @Ooker ,
You can check the apoc.any.properties function which returns a map with a given list of node attributes (it cannot use regex, but if you know the properties of your nodes, you can search the required attributes by name). Please find below an example:
MATCH (s:Student)
UNWIND apoc.any.properties(s,["Z", "Z2"]) AS properties
RETURN properties;
Hope this helps
01-01-2022 05:35 AM
Hello @Ooker
MATCH (x)
WHERE x.name = "a"
RETURN apoc.map.removeKeys(x, [p IN keys(x) WHERE NOT p STARTS WITH "Z"])
Regards,
Cobra
All the sessions of the conference are now available online