MossSession
An on-device index handle for a single index, returned byMossClient.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.
addDocs(_:upsert:)
[DocumentInfo].
deleteDocs(_:)
getDocs(_:)
docIds is nil. An empty
array returns nothing. Returns [DocumentInfo].
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.
loadFromDisk(cachePath:)
save(toCachePath:). 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.