Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
11-06-2020 02:59 PM
Hi all,
In my graph I have the below node-relationship structure :
(Response)-[:isAnswerTo]->(Question)
(Responder)-[:ANSWERED_WITH]->(Response)
Now a Question can be of type multi select i.e. User can select multiple responses as an answer to that question.
So in case I get the below result :
I need to find how many questions have been answered by a responder.
My query :
OPTIONAL MATCH(rs)-[rw:RESPONDED_WITH]->(response)-[:isAnswerTo]->(q)
But this gets both the responses that were selected.
I only need to know if a question was answered or not.
Kindly help.
11-07-2020 06:46 AM
Yes @alexandra I did try count(rw).
The issue with that is that it gives the count as 2 in the case mentioned above.
I want to consider the response only once to get the correct number of questions answered
11-06-2020 07:12 PM
Try this:
// find all the questions that were answered.....
match (q:Question)-[]->(r:Response)
with q, r
//find count of answered questions per each responder.....
match (u:Responder)-[]->(r)-[]-(q)
return u.name as usr, count(q) as cnt
11-07-2020 06:49 AM
HI @ameyasoft
Thanks for your response.
I need optional match because i want to get the total questions as well.
I am hoping to get :
total questions : 10
responded : 4
11-07-2020 09:04 AM
Try this:
// find all the questions that were answered.....
match (q:Question)-[]->(r:Response)
with q, r
//find count of answered questions per each responder.....
match (u:Responder)-[]->(r)-[]-(q)
//find total questions....
match (q1:Questions)
with count(q1) as TotCnt
return u.name as usr, count(q) as cnt, TotCnt
11-07-2020 07:41 AM
Thanks for your time @alexandra and @ameyasoft
I was able to get the desired result.
All the sessions of the conference are now available online