Skip to content

SearchMatcher

Unofficial

A node of a compiled search query’s matcher tree.

This is the abstract base every concrete matcher extends (text, regex, property, boolean, file:, tag: and the other operators, and the AND / OR / negation operators). SearchMatcher.getInfo, SearchMatcher.match and SearchMatcher.requiredInputs are implemented by every concrete matcher; the base class declares the token bookkeeping.

Import:

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

Signature:

export interface SearchMatcher

Properties

PropertyTypeDescription
matchedTokensunknown[]The query tokens this matcher consumed while the query was parsed.

Methods

MethodReturnsDescription
eatToken(state)voidConsumes the parser's current token, recording it in SearchMatcher.matchedTokens.
getContext(offset)null | SearchMatcherTokenContextFinds the matcher that owns the query token at a cursor offset.
getInfo()stringDescribes this matcher, as shown by the search view's "Explain search term".
match(context)null | SearchMatchResult | undefinedMatches this node against a context.
requiredInputs()SearchRequiredInputsThe inputs this matcher needs to evaluate a file.

Links to this page: