Skip to content

ObsidianSearchQuery

Unofficial

A parsed Obsidian search query, compiled from a raw query string into a matcher. Used by global search, the file explorer filter, and backlink search.

Import:

import type { ObsidianSearchQuery } from '@obsidian-typings/obsidian-public-latest';

Signature:

export interface ObsidianSearchQuery

Constructor

new ObsidianSearchQuery(app: App, query: string, caseSensitive: boolean, operators?: Record<string, unknown> | undefined)

Constructor.

To get the constructor instance, use getObsidianSearchQueryConstructor from obsidian-typings/implementations.

Properties

PropertyTypeDescription
appAppReference to the app.
caseSensitivebooleanWhether the query is matched case-sensitively.
matchernull | SearchMatcherThe root of the compiled matcher tree, or null when the query compiles to nothing (an empty query).
querystringThe raw query string.
requiredInputsnull | SearchRequiredInputsThe inputs the matcher requires to evaluate a file, or null when there is no matcher.

Methods

MethodReturnsDescription
_match(context)null | SearchMatchResultRuns the matcher against a match context.
match(file, content)null | SearchMatchResultMatches a file (and optionally its content) against the query.
matchContent(content)null | SearchMatchResultMatches content against the query.
matchFilename(path)null | SearchMatchResultMatches a file path's name against the query.
matchFilepath(path)null | SearchMatchResultMatches a file path against the query.
matchTag(tag)null | SearchMatchResultMatches a tag against the query.

Links to this page: