loadIndex() (or open a session) before
querying with a filter. The filter is passed as
QueryOptions.filter.
Operators
A single condition compares one metadata field with one operator. The condition shape lists them all.
Compose multiple conditions with
$and / $or (nestable). A single condition can be passed
on its own without a wrapper. The filter shape page describes
the full structure. @moss-js/moss does not export MetadataFilter or FilterCondition:
QueryOptions.filter is typed any, so pass a plain object as in the examples below.
Metadata values are strings. Filter values can be strings or numbers; a Date is rejected.
Examples
Filtering inside a session
The same filter syntax works on a session query, evaluated entirely in-memory.Date ranges
Store dates as Unix epoch seconds in a decimal string and filter with numbers, so both sides compare as numbers. Filter by date explains the encoding and the pitfalls of ISO 8601 strings.Related
- Hybrid search - blend semantic and keyword scoring.
- Sessions - filter inside a live session.
- MetadataFilter and FilterCondition - the filter and condition shapes (documented, not exported).
- SDK reference - the full JavaScript SDK overview.