jeudi 5 février 2015

Neo4j 1.9.2: Query/filter and count multiple node types


Vote count:

0




In Neo4j 1.9.2, I'd like to count all the relationships for EACH node in a set of nodes.


All of my nodes have three properties: type, id, and created. They're all connected by a "follow" relationship. Here's an example of how they fit together:



user('id:1')-[follows]->review('id:1')
user('id:1')-[follows]->user('id:2')
user('id:2')-[follows]->review('id:1')


You get the idea.


The results should be something like this:



review1_data: {
followers: 2,
id: 1
created: 2013-12-13T12:13:42-08:00
...
},
user2_data: {
followers: 1,
id: 2,
created: 2012-02-13T12:13:43-08:00
...
}


The data I'm given is essentially the following:



{
users: [1, 2],
reviews: [1]
}


I've tried queries like this:



start user1=node:user('id:1'),
user2=node:user('id:2'),
review1=node:review1('id:1')

match user1<-[user1_f:follows]-(),
user2<-[user2_f:follows]-(),
review1<-[review1_f:follows]-()

return user1, count(user1_f),
user2, count(user2_f),
review1, count(review1_f);


But obviously this is untenable for large lists of node:id pairs (in fact, Neo dies really hard once the query gets large).


Any idea how to achieve this? I've been pouring over the docs to see if there's some way, but I am not sure there is.



asked 41 secs ago







Neo4j 1.9.2: Query/filter and count multiple node types

Aucun commentaire:

Enregistrer un commentaire