$ cat workspace-template.yaml
Ontology Schema Search
// Answer a RELATIONSHIP or THEME question over the governed organization ontology using schema-aware retrieval: Ontology Search (mode schema/hybrid) matches the question to the relevant object/relationship TYPES via their English descriptions and returns their most-evidenced instances, Merge Ranked Lists builds a readable digest, and Knowledge Synthesizer writes a grounded, cited answer. A focused showcase of the N2 schema/hybrid retrieval modes.
// Canvas Preview
// Instruction
Ontology Schema Search
Overview
This workspace answers a RELATIONSHIP or THEME question over the governed organization ontology using the graph's SCHEMA-aware retrieval. Instead of matching an entity by NAME, Ontology Search (mode schema/hybrid) matches the question to the relevant object/relationship TYPES via their English descriptions, then returns the most-evidenced instances of those types (each carrying matchedVia: which type it matched and why). Merge Ranked Lists turns that ranking into a readable digest, and Knowledge Synthesizer writes a grounded, cited answer. All nodes are read-only and permission-gated inside their backing APIs.
Workflow Chain
Query Crafting (MANDATORY - do this BEFORE filling any node input)
This is the OPPOSITE of a name search: here the query should carry the RELATION / TOPIC words, because the schema arm matches them against type descriptions.
Ontology Search.mode:- Pure relationship/theme question, no specific entity named ("chi ha promulgato le leggi?", "quali adozioni internazionali?", "chi ha firmato accordi?") -> set
mode=schema. - Mixed (a named entity AND a relationship/theme, or you are unsure) -> keep
mode=hybrid(default: runs both arms and fuses them, so a named entity still resolves).
- Pure relationship/theme question, no specific entity named ("chi ha promulgato le leggi?", "quali adozioni internazionali?", "chi ha firmato accordi?") -> set
Ontology Search.query= the RELATION/TOPIC terms, Italian first then English (the corpus is mostly Italian, the type descriptions are English): e.g. "chi ha promulgato la legge | who promulgated the law", "accordi e convenzioni internazionali | international agreements conventions". Keep the relation/topic words - do NOT reduce to a bare entity name.Knowledge Synthesizer.query= the user's ORIGINAL question, VERBATIM AND UNTRANSLATED. Append: "Answer in the same language as this question." Setlanguageto the language the user TYPED in (e.g. "Italiano", "English", "中文") - never the corpus language.
Node Reference
- Ontology Search (input) - schema/hybrid retrieval over the ontology. Inputs:
query(relation/topic terms),mode(schema= by relationship/theme via matching types;hybrid= both arms fused, the default;entity= by name, not used here),type(optional object-type filter, blank = all),limit(default 10). Outputresults(objects, each withmatchedViaprovenance) feeds Merge Ranked ListslistA. - Merge Ranked Lists (process) - here it ranks the single
listA(RRF degrades cleanly with an emptylistB). OutputitemsTextis the readable digest fed to Knowledge Synthesizercontext;itemsis the ranked list;topIdis the top entity. - Knowledge Synthesizer (process) - writes the grounded, cited answer for
queryfrom the fan-incontext. Inputs:llmModelId(empty = the workspace default),language. Outputtextis the final answer.
Execution Strategy
Complete all 3 phases in order.
Phase 1 - Configure
- Make ONE
requestUserDecisionbundling: (a) the question to answer; (b) response language (default Italiano). Keep a free-text box last. Do not prompt again after this. - Use
nodeFinderto get the fresh ids of the three nodes - template-preview ids are stale after cloning. - Apply with ONE
batchUpsertNodes: set Ontology Searchmode(schemaorhybridper rule 1) andquery(the relation/topic terms per rule 2); set Knowledge Synthesizerqueryto the full question andlanguageto the chosen language. Every{{query}}placeholder MUST be replaced here. Phase 1 complete. Now proceed to Phase 2.
Phase 2 - Run
- Execute with
nodeExecutoron the Knowledge Synthesizer node - the upstream Ontology Search and Merge resolve automatically. - Read results with
getNodeOutput: Knowledge Synthesizertext(the answer) and Merge Ranked ListsitemsText(the schema-matched entity ranking). If the answer says no context was available, check Ontology Searchresultsbefore reporting failure - an empty result means no matching types/instances were accessible; suggest rephrasing with clearer relation/topic terms or switchingmodetohybrid. Phase 2 complete. Now proceed to Phase 3.
Phase 3 - Verify and present
- Run
verification, then present the answer with its citations followed by the schema-matched entity ranking, noting for the top entities WHICH type they matched (frommatchedVia) so the user sees why the relationship/theme surfaced them. - In
followUp, offer to: (a) switchmodebetweenschemaandhybrid; (b) sharpen the relation/topic terms; (c) add an entity name to pivot tohybrid. Nothing here writes outside the graph.
Error Handling
- Ontology Search returns empty results - no matching types/instances were accessible, OR the OpenSearch type catalog / kNN flag is unavailable server-side. Try
mode=hybrid, rephrase the relation/topic terms, or fall back to a name search. - A node fails with an authentication error - the workspace owner's token cannot reach the ontology APIs; verify the workspace credentials, then re-run.
// Dependencies
1from node import OntologySearch # v1.4.02from node import MergeRankedLists # v1.3.03from node import KnowledgeSynthesizer # v1.6.0// Variables
1query:2 type: undefined3 label: "Query"4 description: "The user's question, verbatim and IN THE USER'S LANGUAGE. Do NOT bake it into the search node - the instruction's Query Crafting derives the relation/topic terms for Ontology Search; the original goes to Knowledge Synthesizer so the answer comes back in the user's language."5 required: undefined$ git log --oneline