O'Reilly logo

Neo4j Cookbook by Ankur Goel

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Boolean operators with Cypher

Cypher supports the Boolean operators AND, OR, NOT, and XOR, which are very useful to describe more than one condition to be checked simultaneously. In this recipe, we will learn their uses within the graph we have created.

Getting ready

To step through this recipe, you will need to create the nodes and relationships for which data has been provided with the code files.

How to do it...

We have divided this recipe into the following problem sets:

  • The Boolean operator AND with Cypher: Let's get all the flights that originate from any airport in Atlanta city that are destined for Dallas/Fort Worth:
    MATCH (o)<-[:`ORIGIN`]-(f)-[:`DESTINATION`]->(d) where o.city = "Atlanta" AND d.city = "Dallas/Fort Worth" return o,f,d

    The following ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required