Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
11-18-2021 08:15 AM
In the following example:
CREATE (:A)-[:AB{list:['k1:v1', 'k2:v2']}]->(:B)
CREATE (:A)-[:AB{list:['k2:v2']}]->(:B)
To find path with AB.list
having an element k1:v1
, I can use the following query:
WITH 'k1:v1' AS query
MATCH path = (:A)-[ab:AB]->(:B) WHERE query IN ab.list RETURN path
The query above uses an exact match in the list, but I only have a prefix k1:
to query with. Is there a valid Cypher to achieve something like this?
WITH 'k1:' AS queryPrefix
MATCH path = (:A)-[ab:AB]->(:B) WHERE queryPrefix.* IN ab.list RETURN path
Solved! Go to Solution.
11-18-2021 11:47 AM
Maybe you can try some trick with list.reduce()
reduce(totalAge = 0, n IN nodes(p) | totalAge + n.age)
in your case:
WHERE reduce(contains = 0, l IN ab.list | contains + CASE WHEN l CONTAINS 'k1:' THEN 1 ELSE 0 END) > 0
The syntax works, but I did not test it in a similar data set like yours.
11-18-2021 11:47 AM
Maybe you can try some trick with list.reduce()
reduce(totalAge = 0, n IN nodes(p) | totalAge + n.age)
in your case:
WHERE reduce(contains = 0, l IN ab.list | contains + CASE WHEN l CONTAINS 'k1:' THEN 1 ELSE 0 END) > 0
The syntax works, but I did not test it in a similar data set like yours.
All the sessions of the conference are now available online