Search for it, then follow the graph.
OpenSearch finds documents by their words. YANG-DB follows relationships between them. Together, one query can find the guilds that mention a word, then their members, then the dragons those members own. The data and the search stay on the same cluster.
Run the searches on your own engine.
The page uses the Dragons tutorial data. It calls YANG-DB's REST API from your browser. Without an engine it shows results recorded from a real one, marked recorded.
Your engine
- The engine answers at
/health - The Dragons ontology is registered
- The Person index has data
If your browser blocks the request (Safari blocks http:// from an https:// page), open a local copy: docs/examples/search/index.html in a clone of the repository.
Start it and load the data
- Start YANG-DB and OpenSearch with Docker:
cd docker && ./buildDocker.sh Dragons docker compose -f docker-compose-os.yml up -d
- Load the Dragons data. Connect first, then:
- Connect on the left. The full-text filters and the string operators below need YANG-DB 0.13.0 or later. Earlier versions get several of them wrong (KNOWN_ISSUES Q27–Q32).
Search for words, or match part of a value.
A text property is stored twice in OpenSearch. The analysed field holds the value split into lower-cased words, for search. The keyword sub-field holds the value exactly as written. Each filter uses the field that gives it its meaning.
| Filter | Finds | Field | Case | Up to 0.12 | Cypher, from 0.13 |
|---|---|---|---|---|---|
match | any of the words | analysed | ignored | V1 | search.match(x.p, '…') |
match_phrase | the words together, in order | analysed | ignored | V1 | search.match_phrase(x.p, '…') |
query_string | Lucene syntax: AND OR NOT "…" * | analysed | ignored | V1 | search.query_string(x.p, '…') |
fuzzy eq | a word, allowing typos | analysed | ignored | V1 | search.fuzzy(x.p, '…') |
CONTAINS | the text anywhere in the value | keyword | exact | Cypher, V1 contains | no change |
STARTS WITH | the value's beginning | keyword | exact | Cypher, V1 starts with | no change |
ENDS WITH | the value's end | keyword | exact | Cypher, V1 ends with | no change |
=~ | a pattern over the whole value | keyword | exact | Cypher, V1 like | no change |
Every filter works at every position of a pattern: on the node you start from, on the far end of a hop, or several hops away. The planner picks where to start. A filter on a hop's target can be answered from a copy of the field stored on the relationship, so map the copy like the original. The negated forms are in V1 (not match, not contains, fuzzy ne, …). In Cypher, NOT negates a single condition: WHERE NOT d.name CONTAINS 'rax', WHERE NOT search.match(g.description, 'tenetur') (from 0.13; before, Cypher ignored it, Q33).
What there is to search.
The Dragons ontology. Properties of type text can be searched by word. The use cases search guild descriptions (short sentences), and the names of people and dragons. Click a type to see its properties.
Search, then follow the relationships.
Every case is Cypher. The full-text ones use the search functions of YANG-DB 0.13 (search.match, search.match_phrase, search.query_string, search.fuzzy); on 0.12, use the V1 operators in the table above. CI checks every case on every pull request, against answers computed by OpenSearch itself.
Where search + graph is heading.
Planned, not available yet. The IDs refer to the roadmap.
Order by relevance
Order rows by how well the text matched, as OpenSearch scores it, for example the members of the guilds that match best.
… ORDER BY search.score(g) DESC
Similar meaning, then expand
Semantic search: find entities whose embedding is close to a query vector with OpenSearch k-NN, then follow their relationships (the retrieval step of GraphRAG).
WHERE knn(d.embedding, $v, 10)
Search inside a neighbourhood
Run a text, vector or aggregation query only over what a pattern reached, such as the descriptions of the guilds a person's friends belong to.
A tutorial and more data
A step-by-step tutorial built on this page, and the same use cases on the traces example: span names and attributes.