Skip to content

SearchMatchContext

Unofficial

The per-file context a search matcher evaluates against.

Import:

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

Signature:

export interface SearchMatchContext

Constructor

new SearchMatchContext(strings: Record<string, string>, original: string, keys: string[], caseSensitive: boolean)

Constructor.

Properties

PropertyTypeDescription
cacheCachedMetadata | null | undefinedThe metadata cache of the file being matched, when it has one.
caseSensitivebooleanWhether the query is matched case-sensitively.
dataMap<unknown, unknown> | nullValues attached to the context by the matchers, or null when there are none.
keysstring[]The inputs, by name, that the matchers search: a subset of the keys of SearchMatchContext.strings.
originalstringThe original text the context was created for.
stringsRecord<string, string>The input strings by name: content, filename, filepath, propertyName or tag.

Methods

MethodReturnsDescription
clone()SearchMatchContextCopies the context. SearchMatchContext.strings, SearchMatchContext.keys and SearchMatchContext.data are copied; SearchMatchContext.cache is shared.
cloneForPropertyContent(value)SearchMatchContextCopies the context for matching a property value, which becomes the only (content) input.
deleteData(key)voidRemoves a value attached to the context.
getData(key)unknownReads a value attached to the context.
setData(key, value)voidAttaches a value to the context.