Skip to content

Search

The client.search resource provides three search methods: simple text search, Dataview DQL queries, and JsonLogic queries.

Search for text across all files in the vault:

results = await client.search.simple("python asyncio")
for result in results:
    print(f"{result.filename} (score: {result.score})")
    for match in result.matches or []:
        print(f"  ...{match.context}...")

Context length

Control how much surrounding text is included with each match:

results = await client.search.simple("python", context_length=200)

Use Dataview Query Language for structured queries:

results = await client.search.dataview('TABLE file.name FROM "Notes"')
for result in results:
    print(result.filename)
    print(result.result)  # Raw Dataview result data

Note

Dataview DQL search requires the Dataview plugin to be installed and enabled in Obsidian.

Use JsonLogic for programmatic query construction:

results = await client.search.jsonlogic({"glob": ["*.md"]})
for result in results:
    print(result.filename)

Search result structure

Each search method returns a list of SearchResult objects:

Field Type Description
filename str Path to the matching file
score float \| None Relevance score (simple search only)
matches list[SearchMatch] \| None Match locations with context (simple search only)
result Any Raw result data (Dataview/JsonLogic only)

Each SearchMatch contains:

Field Type Description
match dict[str, int] Match start/end positions
context str Surrounding text context