I have graph that looks something like this
MATCH (s {address:"0xb64ef51c888972c908cfacf59b47c1afbc0ab8ac"})<-[:Transfer*]-(t) RETURN s,t
I would like to filter by the relationship property where the value > 0.6 , how do i go about this ?
I have graph that looks something like this
MATCH (s {address:"0xb64ef51c888972c908cfacf59b47c1afbc0ab8ac"})<-[:Transfer*]-(t) RETURN s,t
I would like to filter by the relationship property where the value > 0.6 , how do i go about this ?
Bind the relationship to a variable, and then just use WHERE.
MATCH (s {address:"0xb64ef51c888972c908cfacf59b47c1afbc0ab8ac"})<-[rel:Transfer*]-(t)
WHERE rel.value > 0.6
RETURN s,t
Note that since you have * on that relationship, this will require that every relationship on the path meet that criteria, not just one.
i tried that earlier but i kept running into the the following error
Type mismatch: expected Any, Map, Node, Relationship, Point, Duration, Date, Time, LocalTime, LocalDateTime or DateTime but was List (line 3, column 7 (offset: 97))
"WHERE rel.value > 0.6"
i managed to resolve this using :
MATCH (s {address:"0xb64ef51c888972c908cfacf59b47c1afbc0ab8ac"})<-[rel:Transfer*]-(t)
WHERE all(a in rel where a.value > 0.6)
RETURN s,t
However, there is a warning stating
" This feature is deprecated and will be removed in future versions.
Binding relationships to a list in a variable length pattern is deprecated. (Binding a variable length relationship pattern to a variable ('rel') is deprecated and will be unsupported in a future version. The recommended way is to bind the whole path to a variable, then extract the relationships: MATCH p = (...)-[...]-(...) WITH *, relationships(p) AS rel)"
any idea how do i convert the above query to using the newer recommended method instead?
MATCH path=(s {address:"0xb64ef51c888972c908cfacf59b47c1afbc0ab8ac"})<-[:Transfer*]-(t)
WHERE all(a in relationships(path) where a.value > 0.6)
RETURN s,t
Neo4j Desktop is quite good at giving clues, what syntax to use
Try this:
MATCH p=(s {address:"0xb64ef51c888972c908cfacf59b47c1afbc0ab8ac"})<-[:Transfer]-(t)
WITH *, relationships(p) AS rel
WHERE all (a in rel where a.value < 0.6)
RETURN s,t
I have a slightly more complicated query with the same warning.
The first element in the relationship/list must be a GpLink and all other elements must be Contains.
How might I do that using the preferred method? I don't see any predicates here that allow for ordinal/position filtering, https://neo4j.com/docs/cypher-manual/current/functions/predicate/
MATCH (g:GPO)
OPTIONAL MATCH p = (g)-[r1:GpLink]->(container)-[r2:Contains*1..]->(c:Computer) WHERE NONE(x in NODES(p) WHERE x.blocksinheritance = true AND LABELS(x) = 'OU') WITH g,p,container,c
WHERE c.operatingsystem CONTAINS 'Server'
RETURN g.name as GPName, count(distinct(c.name)) as ComputersControlled, g.distinguishedname as DistinguishedName
ORDER BY ComputersControlled DESC