liveBook · Manning

Cypher

As explained in Knowledge Graphs and LLMs in Action

Cypher is a declarative graph query language for matching patterns and reading or modifying property-graph data.

Cypher is a declarative query language for LPG knowledge graphs. It expresses graph patterns directly, making relationships and relationship-level metadata readable and accessible for querying, integration, and updates. section 3.2.2 section 3.2

A practical Cypher workflow commonly proceeds as follows:

  • Match nodes and relationships by labels, types, identifiers, and graph patterns. section 3.2.2
  • Filter matched entities with conditions such as disease and phenotype identifiers. section 3.2.2
  • Return node, relationship, or property values, including annotation source, creator, and creation date. section 3.2.2
  • Load tabular data, merge entities and relationships, conditionally set properties, batch-enrich records, and delete unnecessary graph elements. section 3.3.2 section 3.3.2

Retrieving annotated disease–phenotype relationships

MATCH (d)-[r:HAS_PHENOTYPIC_FEATURE]->(p) WHERE d.id = "OMIM:222100" and p.id = "HP:0410050" RETURN r.source, r.createdBy, r.creationDate This query follows a disease-to-phenotype relationship, restricts both endpoint identifiers, and returns metadata stored directly on the relationship. The same representation supports evidence, onset, frequency, sex, and other annotation properties. section 3.2.2 section 3.3.2

Listing 3.12 Example Cypher query
MATCH (d)-[r:HAS_PHENOTYPIC_FEATURE]->(p)
WHERE d.id = "OMIM:222100" and p.id = "HP:0410050"
RETURN r.source, r.createdBy, r.creationDate

Inspect the complete Cypher listing for matching a disease–phenotype pattern, filtering endpoint identifiers, and returning relationship annotations. section 3.2.2

Figure 14.11 The complete flow of transforming a natural language question into a Cypher query, showing how three inputs are processed through structured prompt components. The process is organized into three stages (Input processing, Context building, and Final guidelines) that culminate in structured JSON output.
figure

Follow the structured pipeline that turns a natural-language question, schema annotations, and intent requirements into a Cypher query. section 14.7.2

How Knowledge Graphs and LLMs in Action covers it

How deep it goes
Explains pattern matching, filtering, returning, loading, conditional updates, batching, and deletion, but does not detail language internals.
Examples
Uses disease–phenotype metadata queries, HPOA tabular ingestion, relationship enrichment, graph cleanup, and structured query-generation prompts.
What it assumes
Assumes familiarity with nodes, relationships, properties, schemas, and knowledge graphs while illustrating these through biomedical data.
What you can do after
Builds and queries annotated LPG knowledge graphs, including loading data, enriching relationships, and generating queries from structured questions.
How it connects
Connects LPG, Neo4j, RDF, SPARQL, ontologies, knowledge-graph construction, and natural-language question answering.

Also explained in

Compare how 4 books explain Cypher →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Knowledge Graphs and LLMs in Action. The section links point to the parts of the book it draws on.