samedi 18 avril 2015

neo4j random nodes output

I have a campaign node which has a relationship with Picture node.


I'm trying to get , in each campaign that the query finds , a random picture which connected to it.


I managed to get a random picture to a single campaign, but if I want to each campaign a connected picture output, I'm having trouble to do it.


This is an example to get a single picture to within a campaign.



MATCH (campaign:Campaign)-[]-(picture:Picture) where
campaign.id="1429184083571" or campaign.id='1429182615443'
WITH picture, rand() AS r,campaign
ORDER BY r
RETURN campaign,picture
limit 1


How can i get an output for each campaign a connected random picture ?





Aucun commentaire:

Enregistrer un commentaire