The index API provides functions for interacting with SilverBullet's Object Index, including query collections used by Space Lua/Integrated Query, schema introspection, ad-hoc Markdown indexing, and direct object-index operations.
The main query API is index.objects; the other collection functions are mostly convenient filters over the same index.
index.aggregates()
Returns stored aggregate records as a query collection.
index.ambiguousLinks()
Returns links whose page name matches more than one page as a query collection.
index.aspiringPages()
Returns linked but not yet created pages as a query collection.
index.clearFileIndex(path)
Drops every indexed object belonging to a file, so a re-index replaces them rather than merging on top.
index.contentPages(tagName?)
Returns non-meta pages, optionally filtered by a user tag, as a query collection.
index.data(tagName?)
Returns objects from fenced data blocks (```data and ```#name), optionally filtered by a tag, as a query collection. See Tag/data.
index.defineTag(tagDefinition)
Defines or updates a tag and its Lua metatable.
index.deleteObject(page, tag, ref)
Removes an object from the index without changing its page; it comes back the next time the page is indexed. To delete an object from its page, use object.delete.
index.describeSchema()
Returns raw JSON Schemas for every configured tag that declares one.
index.documents()
Returns all indexed documents as a query collection.
index.ensureFullIndex()
Ensures the complete object index is available and current.
index.extractFrontmatter(text, options?)
Extracts and optionally transforms frontmatter and top-level tags in Markdown text.
Parameters:
text (string) — Markdown text to inspect.options? (table) — Optional frontmatter and tag removal settings.Returns:
table — Parsed frontmatter and the optionally transformed text.index.getObjectByRef(page, tag, ref)
Returns an indexed object identified by page, tag, and reference.
index.headers(tagName?)
Returns all headers, optionally filtered by a user tag, as a query collection.
index.indexObjects(page, objects)
Indexes a collection of objects for a page.
index.isAvailable()
Whether a full indexing pass has ever completed for this space. False on a fresh client, and for as long as the first index takes on a large one: every object query answers with whatever has been indexed so far, which is nothing to begin with. Code that must work in that window reads the space directly instead.
Returns:
boolean — Whether the index can be trusted.index.items(tagName?)
Returns all list items, optionally filtered by a user tag, as a query collection.
index.links()
Deprecated: returns all indexed links, a view over relations, as a query collection. Use #index.relations instead (see Tag/relation#Deprecated: the link view).
index.markdown(text, pageMeta?)
Indexes Markdown text in memory and returns the objects extracted from it.
Parameters:
text (string) — Markdown text to index.pageMeta? (table) — Optional page metadata used during indexing.Returns:
table — Objects extracted from the Markdown text.index.metaPages(tagName?)
Returns meta pages, optionally filtered by a user tag, as a query collection.
index.objects(tagName)
Returns objects carrying a tag as a query collection.
index.pages(tagName?)
Returns all pages, optionally filtered by a user tag, as a query collection.
index.paragraphs(tagName?)
Returns indexed paragraphs, optionally filtered by a user tag, as a query collection.
index.patchFrontmatter(text, patch)
Applies a table of updates to the frontmatter in Markdown text.
Parameters:
text (string) — Markdown text to update.patch (table) — Frontmatter keys and values to merge.Returns:
string — Markdown text with updated frontmatter.index.previewProcessedObjects(page, objects)
Runs the indexing pipeline without writing and returns processed tag/object pairs.
index.queryLuaObjects(tag, query, scopedVariables?)
Executes a structured Lua collection query against indexed objects.
index.reindexSpace()
Rebuilds the object index for the entire space.
index.relations(kind?)
Returns all indexed relations, optionally filtered by kind, as a query collection.
index.resolveAnchor(name, page?)
Resolves a named anchor to its host page, tag, and source range.
Parameters:
name (string) — Anchor name without the leading dollar sign.page? (string) — Optional page to restrict the lookup to.Returns:
table — Resolution result including success or missing/duplicate reason.index.subPages(pageName)
Returns pages nested below a page name as a query collection.
index.tables(tagName?)
Returns indexed table rows, optionally filtered by a user tag, as a query collection.
index.tag(tagName)
Returns objects carrying a tag as a query collection.
index.tagSchema(tagName)
Returns the raw JSON Schema for a tag, or nil when none is declared.
index.tags()
Returns all indexed tag objects as a query collection.
index.tasks(tagName?)
Returns all tasks, optionally filtered by a user tag, as a query collection.
index.validateObjects(page, objects)
Validates objects for a page and returns the first validation error, if any.
Query one page:
${queryfrom index.pages() limit 1}
Query three sub-pages below the API page:
API/asset API/capture API/clientStore
Render three incomplete tasks:
Ad-hoc index a Markdown fragment and select its list items:
${query[[ from index.markdown("* Item 1\n* [ ] Task 1") where _.tag == "item" ]]}
index.extractFrontmatter can inspect and optionally transform frontmatter and top-level tags. For example, this returns the frontmatter of the current page:
${(index.extractFrontmatter(editor.getText())).frontmatter}