Skip to content

Lesson 3 Pattern Matching

Christopher Rost edited this page Sep 4, 2020 · 15 revisions

Have a look at the Wiki pages of Gradoop - Query for further details about this operator.

Test Data Schema

LDBC Schema

All labels start with a lowercase letter in our dataset, so please use 'person' instead of 'Person' in your tasks.

Task 1 - Friendship Graph

  • Find all persons that know "John Jones".
Solution
  "MATCH (p1:person)-[:knows]->(p2:person) WHERE p2.firstName=\"John\" AND p2.lastName=\"Jones\""

How many persons know him? Answer: 2

Task 2 - Locations

  • Find all entities that are located in Bangkok
Solution
  "MATCH ()-[:isLocatedIn]->(c:city) WHERE c.name=\"Bangkok\""

Task 3 - Construct

  • Find all Persons that are creators of Posts located in "Senegal"
  • Posts should not be in the result set (use construct pattern)
  • See the documentation about construct pattern here
Solution
    "MATCH (p:person)<-[:hasCreator]-(:post)-[:isLocatedIn]->(co:country) WHERE co.name=\"Senegal\"",
    "(p)-[e_new:isLocatedIn]->(co)"
Clone this wiki locally