EigenQL user guide
EigenQL is the read-only query language for the Eigenius knowledge graph. It lets you match patterns against layered Eigon resources, derive relations with DEFINE, dispatch to institution reasoners via FIBER clauses and qualified-name function calls, and shape the results into self-describing Eigon documents.
This guide is written against the implementation in kernel/src/query/ and the specification in D2. Every feature described here is grounded in source — chapters link directly to the modules that implement them.
How to read this guide
The chapters are ordered for sequential reading: each builds on concepts introduced earlier. If you already know SQL, Cypher, or Datalog, you can skim chapter 2 to calibrate, then jump to whichever later chapter matches your question.
As a reference, the most useful chapters are:
- 4. Program structure — what clauses exist, in what order, and how they compose
- 6. Text and vector retrieval — the D43 fuzzy-retrieval surface (
~operator, indexes,TOP N) - 7. Expressions — the expression sublanguage used in
WHERE,RETURN,GROUP BY,ORDER BY - 13. Appendix — EBNF grammar, keyword list, built-in function table, operator precedence, source index
Chapters
-
Introduction — what EigenQL is, how it sits beside ESL, the six-stage execution pipeline, and the single entry point (
execute_with). -
Quick tour — seven worked examples drawn from the test suite: listing classes, filtering, recursive
DEFINE(transitive closure),GROUP BYwith aggregates, aFIBERclause, and a decide predicate inWHERE. -
Lexical structure — tokens, keywords (structural, operator, built-in function, literal), identifiers, variables (
?name), qualified names, literals, operators, punctuation, comments, and whitespace rules. -
Program structure — clause-by-clause reference:
USING,USING INSTITUTION,DEFINE,MATCH,WHERE,FIBER,RETURN,GROUP BY,ORDER BY,LIMIT/TOP/OFFSET/DISTINCT, and howQuery/MatchPartare shaped internally. -
Pattern matching — how
MATCHworks: subject variables, class predicates with subclass-chain walking, property patterns against IRI / literal / variable targets, negation semantics, and multi-pattern equi-joins. -
Text and vector retrieval — the D43 surface: the
~similarity operator, schema-sideTextIndex/VectorIndexdeclarations, the{ via, model, k, limit }hint block,TOP Nranked truncation, hybrid retrieval and internal RRF fusion, embedder registration, worked examples (text-only / vector-only / hybrid / structural composition), and the failure-mode catalogue. -
Expressions — per-variant reference for the expression AST: literals, variables, binary ops (11 operators), unary ops,
NOT EXISTS, function calls (three dispatch paths), aggregates, dot-paths, arrays, precedence, and type coercion rules. -
FIBER clauses — structured institution dispatch: query-class-typed parameter objects, the transient overlay, the determinism guarantee via synthesized response IRIs, and a full multi-step example.
-
Institutions in EigenQL — how EigenQL dispatches to registered institutions under D14: the
InstitutionIndexderived from the chain, DecidableQueryClasscalls returningVerdict, the postfixHOLDS/FAILS/UNDECIDABLEpredicates, comorphism coercion in FIBER params, and the classification table shared with ESL. -
Stratification — why the stratifier exists, what a negation cycle looks like, how strata are assigned, the
FIBER-in-DEFINErestriction, and safe patterns for combining recursion and negation. -
Result format — the two result shapes (with / without
RETURNitems), synthesized IRIs viaQueryFingerprint, a full walk-through of a result document, data-type inference forPropertyresources, and how to consume results programmatically. -
Error messages — the
QueryErrorstructure, common errors per phase (Lexer / Parser / TypeCheck / Stratification / Evaluation), and a debugging flow that uses the phase tag to localise faults. -
Appendix — EBNF grammar reference, keyword list, built-in function table, operator precedence, result-document IRI constants, institution capability method reference, execution entry points, related documents, and a full source index.
Related documents
- EigenQL specification (D2) — the authoritative grammar and semantics. This guide is derived from D2 but adds worked examples and implementation pointers.
- Institution Realisation (D14) — the institution model
FIBERand qualified-name calls dispatch through: ontology-first declarations (Institution,ExportFormat,ImportFormat,QueryClass,Comorphism), the three-methodInstitutiontrait (extract_typed/reify/query), triadic comorphism realisation, and the dispatch model. Supersedes D10. - Eigon serialization format (D1) — the resource / value model that EigenQL reads from and writes to.
- ESL user guide — the companion surface language for declaring ontologies and programs.
Source index
All implementation referenced in this guide lives in kernel/src/query/ and kernel/src/institution/. See appendix §13.9 for the complete file-by-file list.
Ready to start? → 1. Introduction