Add 'DISTINCT person' to optimize query
// If you would like to test the query in the browser, replace the values of
// $minPathDistance and $maxPathDistance to a constant.
MATCH
- (:Person {id: $personId})-[:KNOWS*$minPathDistance..$maxPathDistance]-
- (person:Person)-[:IS_LOCATED_IN]->(:City)-[:IS_PART_OF]->
- (:Country {name: $country}),
+ (:Person {id: $personId})-[:KNOWS*$minPathDistance..$maxPathDistance]-(person:Person)
+WITH DISTINCT person
+MATCH
+ (person)-[:IS_LOCATED_IN]->(:City)-[:IS_PART_OF]->(:Country {name: $country}),
(person)<-[:HAS_CREATOR]-(message:Message)-[:HAS_TAG]->(:Tag)-[:HAS_TYPE]->
(:TagClass {name: $tagClass})
MATCH (message)-[:HAS_TAG]->(tag:Tag)
