MossClient.session(_:options:). All embedding
runs locally with the bundled model; queries don’t hit the network.
A session can be persisted to disk (save / loadFromDisk) or synced to the
cloud (pushIndex / loadIndex).
The class is thread-safe. close() (also called on deinit) blocks until
in-flight calls return before freeing the native handle.
Example
Properties
name
docCount
Methods
close()
deinit. Later calls throw MossError with the message
MossSession already closed.
addDocs(_:upsert:)
[DocumentInfo].
deleteDocs(_:)
getDocs(_:)
docIds is nil. An empty
array returns nothing. Returns [DocumentInfo].
getDocs(ids:)
getDocs(where:sortBy:ascending:)
filter with the typed Filter DSL; sortBy orders by a
metadata field (numeric-aware).
getDocs(options:)
ids, filter, sortBy,
ascending, and groupByParent via GetDocsOptions.
See the Exact / Graph Retrieval guide for worked examples
of all four overloads, the Filter DSL, and parent grouping.
query(_:options:)
q on-device and runs a local similarity search. Tune with
QueryOptions - hybrid alpha and metadata
filtering are covered in the Querying guide. Returns a
SearchResult.
query(_:embedding:options:)
save(toCachePath:)
cachePath so it can be reopened
on the next launch without re-embedding. Without a path, the snapshot goes in
the app’s Library/Caches/moss/sessions/<project id>/, which the system may
purge, or in sessions/<project id>/ under the MOSS_SESSION_CACHE_PATH
environment variable when it is set. Only session snapshots read that variable.
loadFromDisk(cachePath:)
save(toCachePath:). Without a path,
it reads the directory that save(toCachePath:) uses without one. Returns the
document count restored. The session’s name must match the one used at save
time.
pushIndex()
PushIndexResult with a jobId; poll
MossClient.getJobStatus until the status is
ready.
loadIndex(_:)
0 if no such cloud index). The session then behaves as
a local one - subsequent add/delete/query don’t hit the network.