5

Filtering, Sorting, and Aggregations

In the last chapter, we looked at basic querying using Cypher. In this chapter, we will take it a step further by discussing adding filtering, sorting, and aggregations to the querying. We will cover these aspects in this chapter:

  • Filtering with node labels and relationship types
  • Filtering with WHERE and WITH clauses
  • Sorting data using the ORDER BY clause
  • Working with aggregations

We will start by filtering the data in queries.

Filtering with node labels and relationship types

In Cypher, filtering starts with the usage of node labels and relationship types. Let us take a look at a query where we do not apply any filters in Cypher:

MATCH p=()—-() RETURN p

This query returns all paths where any nodes are ...

Get Graph Data Processing with Cypher now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.