YANG-DB › Examples › Dragons

The Dragons world, as a graph.

YANG-DB's tutorial domain: people, dragons, horses, guilds and kingdoms, and who owns, knows, fights or rules whom. See its ontology, the OpenSearch indices it lives in, run its queries, and save a query's results to slice them with aggregations.

6entity types
9relationship types
1,623entities
20,528relationships
19indices
Step 1 · Connect

Run everything on your own engine.

The page talks to YANG-DB's REST API straight from your browser. Without an engine it shows results recorded from a real one, marked recorded, so you can explore first and run later.

Your engine

  • The engine answers at /health
  • The Dragons ontology is registered
  • The Person index has data

The engine allows requests from any origin, so this works from yang-db.github.io to localhost. If your browser blocks it (Safari blocks http:// from an https:// page), open a local copy instead: docs/examples/dragons/index.html in a clone of the repository.

Start it and load the data

  1. Start YANG-DB and OpenSearch with Docker. The image is built from source (about 5 minutes the first time):
    cd docker && ./buildDocker.sh Dragons
    docker compose -f docker-compose-os.yml up -d
  2. Load the tutorial data: the ontology, its indices and 15 CSV files. Connect first, then:
    or python3 docker/e2e/load_tutorial.py --reset
  3. Connect on the left. All set: explore the schema.

Every step in detail: the Dragons tutorial.

Step 2 · The schema

An ontology: the types, not the storage.

Queries are written against the ontology (Dragons.json): entity types, relationship types and their properties. Click a type to see its properties and where it is stored; drag the nodes to rearrange them.

Click a node or an arrow · drag to move
Step 3 · The indices

Where the graph lives in OpenSearch.

The index provider (DragonsIndexProvider.conf) maps each type onto indices. Most get one index each. Fire and Freeze are split into partitions by year, and Profession is nested inside the person documents. Every relationship is stored twice, once from each end.

Document counts are those of the tutorial data. Connect to count your engine's data.
Step 4 · Queries

Ask the graph in Cypher.

Pick a query, edit it if you like, and run it. The result is drawn as a graph, listed as rows, or shown as the JSON the API returns. These are the tutorial's queries; CI runs them against OpenSearch on every pull request and checks their answers.

Q1

Step 5 · Projection

Save a query's results, then slice them.

With the projection cursor, the engine writes every result row into an OpenSearch index. Run an expensive query once, then summarise its rows, break them down by any field and page through them, without running it again. recorded