Hi,
Try this query:
MATCH (w)-[r:WRITES]->(a)
RETURN w.id, count(r) as Cnt ORDER BY Cnt desc;
Here 'id' is a property on 'w' ( you insert your own property).
This should show a list of 'w' nodes and total number of 'a' nodes connected
in the descending order.
-Kamal
On Saturday, 18 August 2018 04:43:02 UTC-7, Shashika Ranga Muramudalige
wrote:
>
> Hi,
>
>
> I need to query the following graph (query graph) or its sub-graphs from
> my dataset in neo4j.
>
>
> [image: stackoverflow.png]
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> * Figure : Query graph*
>
>
> I have tried with the following query.
>
> OPTIONAL MATCH (w:W)-[:WRITES]->(a1:A{name:"A1"})
> WITH w,a1
> OPTIONAL MATCH (w)-[:WRITES]->(a2:A{name:"A2"})
> WITH w,a1,a2
> OPTIONAL MATCH (w)-[:WRITES]->(a3:A{name:"A3"})
> WITH w,a1,a2,a3
> OPTIONAL MATCH (w)-[:WRITES]->(a4:A{name:"A4"})
> RETURN w,a1,a2,a3,a4
>
>
> But it doesn't give me the accepted results because it is still a logical
> AND operation. Further, results depend on the order of the match in the
> query too.
>
> I think I need a kind of an approach.
>
> MATCH (w:W)-[:WRITES]->(a1:A{name:"A1"})
>
> *OR/AND*
>
> MATCH (w)-[:WRITES]->(a2:A{name:"A2"})
>
> *OR/AND*
>
> MATCH (w)-[:WRITES]->(a3:A{name:"A3"})
>
> *OR/AND*
>
> MATCH (w)-[:WRITES]->(a4:A{name:"A4"})
> RETURN w,a1,a2,a3,a4
>
>
>
> Do I have any luck to achieve this with Neo4j? Your comments are highly
> appreciated.
>
>
> Thanks a lot.
>
> Best Regards,
> Shashika
>
>
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.