MossSession.query takes a
QueryOptions that controls result count, the
semantic/keyword blend, and metadata filtering.
Result count
topK caps how many documents come back (default 5).
Hybrid search (alpha)
alpha blends dense (semantic) and sparse (keyword) scoring:
1.0- pure semantic0.0- pure keyword0.8- default (semantic-heavy)
alpha against your eval set to find the blend that maximizes recall for
your data.
Metadata filtering
Attach metadata when you add documents:filterJson - a JSON string
describing the filter. A single-field filter has the shape:
$and / $or:
Operators
Examples
Swift raw string literals (#"..."#) let you write the JSON without escaping
quotes:
QueryResult.metadata, so you can inspect or
post-process the matched fields.
Custom embeddings
To use your own embedding model instead of the on-device one, open the session withmodelId: "custom". Moss then skips on-device embedding and you supply the
vectors yourself - both when adding documents and when querying:
Fetch by id
To pull specific documents back (for example, to follow references between records), usegetDocs: