$ cat workspace-template.yaml

O

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.

Composition
#ontology#retrieval#schema#hybrid#knowledge-graph#rag

// Canvas Preview

canvas.flow

// Instruction

instruction.md

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

Ontology Search (results) -> Merge Ranked Lists (listA) -> (itemsText) -> Knowledge Synthesizer (context)Knowledge Synthesizer (text) = the final answer

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.

  1. 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).
  2. 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.
  3. Knowledge Synthesizer.query = the user's ORIGINAL question, VERBATIM AND UNTRANSLATED. Append: "Answer in the same language as this question." Set language to 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). Output results (objects, each with matchedVia provenance) feeds Merge Ranked Lists listA.
  • Merge Ranked Lists (process) - here it ranks the single listA (RRF degrades cleanly with an empty listB). Output itemsText is the readable digest fed to Knowledge Synthesizer context; items is the ranked list; topId is the top entity.
  • Knowledge Synthesizer (process) - writes the grounded, cited answer for query from the fan-in context. Inputs: llmModelId (empty = the workspace default), language. Output text is the final answer.

Execution Strategy

Complete all 3 phases in order.

Phase 1 - Configure

  1. Make ONE requestUserDecision bundling: (a) the question to answer; (b) response language (default Italiano). Keep a free-text box last. Do not prompt again after this.
  2. Use nodeFinder to get the fresh ids of the three nodes - template-preview ids are stale after cloning.
  3. Apply with ONE batchUpsertNodes: set Ontology Search mode (schema or hybrid per rule 1) and query (the relation/topic terms per rule 2); set Knowledge Synthesizer query to the full question and language to the chosen language. Every {{query}} placeholder MUST be replaced here. Phase 1 complete. Now proceed to Phase 2.

Phase 2 - Run

  1. Execute with nodeExecutor on the Knowledge Synthesizer node - the upstream Ontology Search and Merge resolve automatically.
  2. Read results with getNodeOutput: Knowledge Synthesizer text (the answer) and Merge Ranked Lists itemsText (the schema-matched entity ranking). If the answer says no context was available, check Ontology Search results before reporting failure - an empty result means no matching types/instances were accessible; suggest rephrasing with clearer relation/topic terms or switching mode to hybrid. Phase 2 complete. Now proceed to Phase 3.

Phase 3 - Verify and present

  1. 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 (from matchedVia) so the user sees why the relationship/theme surfaced them.
  2. In followUp, offer to: (a) switch mode between schema and hybrid; (b) sharpen the relation/topic terms; (c) add an entity name to pivot to hybrid. 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

requirements.py
1from node import OntologySearch  # v1.4.02from node import MergeRankedLists  # v1.3.03from node import KnowledgeSynthesizer  # v1.6.0

// Variables

variables.yaml
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

v1.0.1
HEAD
2026-07-24
v1.0.02026-07-24