I have a relation like this:
context-[EXPRESSED_AS]->root
Assume that I have two contexts. The first has roots with base_forms of "temperature", "cool" and "hot". The second has roots with base_forms of "cool" and "hot". I want to find all contexts, sorted by the number of matches for the set ["cool", "temperature"].
I attempted it using this Cypher query, which doesn't work since the IN operator returns true or false instead of the matches:
"MATCH (w:`context`), s-[EXPRESSED_AS]->n1 WHERE n1.base_form in ["cool", "temperature"] WITH s, COUNT(n1.base_form in ["cool", "temperature"]) AS rootCount RETURN s.name, rootCount ORDER BY rootCount
Any help is appreciated!
I need to get the contexts back with the counts. I amended your suggestion to this:
This returns the contexts in the expected order, but their c values are the same.