Another Word For It Patrick Durusau on Topic Maps and Semantic Diversity

March 17, 2013

Matching Traversal Patterns with MATCH

Filed under: Cypher,Graphs,Neo4j — Patrick Durusau @ 5:17 am

Cypher basics: Matching Traversal Patterns with MATCH by Wes Freeman.

From the post:

“Because friends don’t let friends write atrocious recursive joins in SQL.” –Max De Marzi

The match clause is one of the first things you learn with Cypher. Once you’ve figured out how to look up your starting bound identifiers with start, you usually (but not always) want to match a traversal pattern, which is one of Cypher’s most compelling features.

The goal of this post is not to go over the syntax for all of the different cases in match–for that the docs do a good job: Cypher MATCH docs. Rather, I hoped to explain more the how of how match works.

First, you need to understand the difference between bound and unbound identifiers (sometimes we call them variables, too, in case I slip up and forget to be consistent). Bound identifiers are the ones that you know the value(s) of–usually you set these in the start clause, but sometimes they’re passed through with with. Unbound identifiers are the ones you don’t know the values of: the part of the pattern you’re matching. If you don’t specify an identifier, and instead just do a-->(), or something of that sort, an implicit unbound identifier is created for you behind the scenes, so Cypher can keep track of the values it’s found. The goal of the match clause is to find real nodes and relationships that match the pattern specified (find the unbound identifiers), based on the bound identifiers you have from the start.

Wes is creating enough of these mini-tutorials that you will find his Cypher page, a welcome collection point.

No Comments

No comments yet.

RSS feed for comments on this post.

Sorry, the comment form is closed at this time.

Powered by WordPress