I'm using neovis.js in my web app to connect with neo4j db where there are a node (:user)
and some nodes (:Friend)
For each nodes (:Friend)
there are a relationship [:FRIEND]
between they and the (:user)
like in the screen below
Some nodes (:Friend)
are connected by a relationship [s:TAGGED_TOGETHER]
like in the screen below, which have an attribute s.tagged_together
Every nodes (n:Friend)
have an attribute n.timestamp.
My goal is to return every relationship [:TAGGED_TOGETHER]
greater then a specific value and every relationship [:FRIEND]
in a specific range of time
I write this query
MATCH x=(:fbUser)-[:FRIEND]-(f)
OPTIONAL MATCH y=(f)-[s:TAGGED_TOGETHER]-(d:Friend)
WITH x,f,y,s,d, case d when null then [] else [1] end as iterList
WHERE
(f.timestamp>'2018/01/01' AND f.timestamp< '2019/01/01' ) AND
ALL (x in iterList WHERE
s.tagged_together>=0)
RETURN x,y
But in this way the query return for each node (n:Friend)
all the [:TAGGED_TOGETHER]
relationship.
So, I thinked to modify the query as follow:
MATCH x=(:fbUser)-[:FRIEND]-(f)
OPTIONAL MATCH y=(f)-[s:TAGGED_TOGETHER]-(d:Friend)
WITH x,f,y,s,d, case d when null then [] else [1] end as iterList
WHERE
(f.timestamp>'2018/01/01' AND f.timestamp< '2019/01/01' ) AND
ALL (x in iterList WHERE
s.tagged_together>=0 AND d.timestamp>'2018/01/01' AND d.timestamp< '2019/01/01' )
RETURN x,y
But i think that it's incorrect because not all the node (:Friend)
are connected with the (:user)
although they have the timestamp in the range of time specified
How can I correct the query ?