Intersection cypher query is not working

136 views
Skip to first unread message

Shijo c j

unread,
Mar 9, 2015, 6:52:11 AM3/9/15
to ne...@googlegroups.com
Hi all,

I have just started using Neo4j.Now I am working with Cypher queries.Here I am deeply twisted with one intersection query. Here I have Two labels called SourceTwittername And DestTwittername.
SourceTwittername consist of following nodes(source1,source2,source3,source4,source5) and
DestTwittername contain following nodes(dest1,dest2,dest3,dest4,dest5).Some SourceTwittername nodes are followers(relationship) of DestTwittername while some others are friends(relationship) of DestTwittername.

Example

source1-[:follower]->(dest1,dest2)
source1-[:friend]->(dest3,dest4)

source2-[:follower]->(dest1,dest5)
source2-[:friend]->(dest3,dest4,dest5)

I want to get nodes which is common in all cases.Here dest1,dest3,dest4 are common for source1 and source2.


I tried a lot using Intersection query, but it doesn't seems working.Any kind of help will be appreciated.

Andrii Stesin

unread,
Mar 11, 2015, 2:18:43 PM3/11/15
to ne...@googlegroups.com
Would you please mind explaining what you are matching and what do you want to achieve in the form of Cypher statements? I'm somewhat missing what are nodes and what are labels in your task and how many labels each mode may have.

In fact it looks like you want to make 2 collections of nodes and - treating those collections as unordered sets - just find their set intersection, is my assumption correct?

WBR,
Andrii

Michael Hunger

unread,
Mar 13, 2015, 5:09:30 PM3/13/15
to ne...@googlegroups.com
MATCH (source:SourceTwittername) WITH count(*) as sources
MATCH (source:SourceTwittername)-[rel:FOLLOWER|:FRIEND]->(dest:DestTwittername)
WITH type(rel) as type, dest, count(*) as cnt,sources
WHERE cnt = sources
RETURN type, collect(dest)


--
You received this message because you are subscribed to the Google Groups "Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email to neo4j+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages