Skip to content

About

Query your markdown notes using standard RDF/SPARQL

Topics

Resources

Stars

3 stars

Watchers

1 watching

Forks

Repository files navigation

repo-uri osg://repo/local:abdbf4e76ab73069ed43c376a3eab6f89eeb0a4e
tags
repo/os
layout node.js
notes Published as Obsidian plugin

Dot Triples

Query your Obsidian notes with SPARQL. Dot Triples is an alternative to Dataview that uses standard RDF and SPARQL instead of a custom query language.

What it does

Dot Triples indexes your Markdown and Canvas files as RDF triples with dot-triples and stores them in a triplestore. You then query that graph from inside your notes.

The embedded triplifier uses triplifier-md and triplifier-canvas from dot-triples 0.2.1. Canvas edge labels become predicates between linked notes. Canvas files are included in Re-index vault, Sync current file, and automatic indexing on open or save. Each canvas has its own file:///.../Board.canvas named graph. External OSG triplifier mode remains Markdown-only.

You can:

  • Run SPARQL queries in dot-sparql code blocks.
  • Show contextual panels with query results for the current note.
  • Query across many vaults when you use a shared triplestore.

The queries use standard SPARQL. Other RDF tools and external systems (for example MCP servers) can query the same graph.

Features

  • Built-in triplestore: the plugin runs an in-memory triplestore. You do not need external setup to start.
  • Automatic indexing: the plugin indexes a note when you open or save it.
  • Contextual panels: the panel shows query results for the current note.
  • Cross-vault queries: query across many vaults through a shared triplestore.
  • Agent integration: external tools can query the graph through the SPARQL endpoint.

Install

Install with BRAT:

  1. Install the BRAT plugin.
  2. Add this repository: https://github.com/cristianvasquez/dot-triples-plugin.

Or install manually:

  1. Download the release archive from the GitHub releases page.
  2. Extract main.js, manifest.json, and styles.css into <vault>/.obsidian/plugins/dot-triples/.

Quick start

  1. Enable the plugin. It uses the in-memory triplestore by default.
  2. Run the Re-index vault command to index your notes.
  3. Add a dot-sparql code block to a note:
SELECT ?p ?o WHERE {
  ?s ?p ?o .
} LIMIT 5

This query shows 5 triples.

To query the current note, use the note name as the subject:

SELECT ?p ?o WHERE {
  [[Current Note]] ?p ?o .
}
  1. Open the panel to show contextual queries for the current note.

Template tokens

The plugin replaces these tokens before it sends the query:

  • __THIS__: the current note name URI (urn:name:NoteName).
  • __DOC__: the current note file URI (file:///absolute/path).
  • __REPO__: the current vault repository URI.
  • __property__: a property placeholder (for example, __label__ becomes <urn:token:label>).
  • [[Note Name]]: a wiki link. The plugin converts it to a name URI.

Upgrading to dot-triples 0.1.1

Run Re-index vault after upgrading to replace stored triples. The plugin migrates the previous default panel discovery query; update custom queries yourself.

  • Frontmatter tags now uses schema:keywords, and title uses rdfs:label.
  • Files link to their notes and headings through schema:about. Prose links use dct:references.
  • Code blocks use schema:hasPart, schema:programmingLanguage, and resource:selector with oa:exact for their text.
  • Use https://schema.org/ for schema: and osg://vocab/resource# for resource:.

The embedded triplifier keeps the library's urn:name:Note.md file subject inside the file:///.../Note.md named graph. __DOC__ identifies that graph; __THIS__ identifies the note. Names preserve case, and heading links such as [[Note#Heading]] resolve to urn:name:Note%23Heading. Body fields still use urn:token: predicates; domain types require downstream mappings.

Copy the updated example panels into your vault to replace queries that use the old vocabulary.

Example panels

The example-panels/ directory has ready-to-use query panels for backlinks, statistics, navigation, tags, and more. Each panel is a note with the panel/query tag.

Commands

  • Open panel: show the query panel for the current note.
  • Insert example SPARQL code-block: add a query template at the cursor.
  • Insert named query template: add a titled query block at the cursor.
  • Sync current file: index the current note.
  • Re-index vault: index all notes in the vault.
  • Refresh panel: reload the panel and render it again.

Settings

  • Query URL: the SPARQL endpoint. Set it to use an external triplestore instead of the built-in one.
  • Panel tag: the tag that marks panel notes. The default is panel/query.
  • Panel SPARQL query: the query that finds panel notes. It must return ?document, ?title, and ?content.
  • Index on open / Index on save: index a note automatically when you open or save it.

Development

pnpm install       # install dependencies
pnpm run build     # production build into main.js
pnpm exec vitest run   # run the tests once

About

Query your markdown notes using standard RDF/SPARQL

Topics

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages