Skip to content

SearchRelevance

Unofficial

Scores search results for the byRelevance sort order of a ResultDom.

A search builds one per query from the query’s matcher. An exact title or alias match ranks highest; other matches are weighted by where each term matched and how close it was to a whole word.

Import:

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

Signature:

export interface SearchRelevance

Properties

PropertyTypeDescription
appAppThe app instance.
caseSensitivebooleanWhether the query matches case-sensitively.
matcherSearchMatcherThe root of the query's compiled matcher tree.

Methods

MethodReturnsDescription
matchesTitle(file)booleanCheck whether any term of the query matches the file's name.
score(file, result, content)numberCompute a file's relevance score for the query. A higher score sorts first.

Links to this page: