Skip to the content
hinny

Guides

Filter results

Narrow a search to a subset of documents using their stored attributes.

Apply a filter

Continue with the notes namespace from the quickstart. The kind attribute was declared as a string when the namespace was created.

Python
from hinny import attr

tasks = attr("kind") == "task"
hits = docs.query(text="lease", filter=tasks)
print([hit.key for hit in hits])  # [1]

Combine conditions

Use parentheses around comparisons. Combine filters with & for intersection, | for union, or ~ to exclude matches.

Python
selected = tasks | (attr("kind") == "reminder")
print(docs.count(selected))  # 2