MossClient
The entry point for the Swift SDK. Construct it with your project credentials (or a customAuthenticator), then open on-device
sessions and track push jobs.
All methods are async throws and dispatch native work onto a background
thread. The underlying native client is thread-safe.
Example
Constructors
init(projectId:projectKey:)
init(projectId:authenticator:baseUrl:)
Authenticator. Use this in shipped apps so the
long-lived project key stays on your backend.
Statics
sdkVersion
setModelCacheDir(_:)
<Library/Caches>/moss-models/ automatically
on first init. Call it before constructing your first client if you need a
custom location (e.g. a shared App Group container).
Methods
close()
deinit.
session(_:options:)
MossSession. Documents are embedded
locally with the bundled model (default moss-litelm on iOS) and queried
without a network round-trip. Configure with
SessionOptions — including
autoLoadOnInit to skip the creation-time cloud load
for a local-first startup.
autoLoadOnInit: false so creation returns
immediately and you control loading (restore from disk, hitting the cloud only
on a miss):
createIndex(_:docs:modelId:)
modelId is nil the server picks a default ("custom" when documents
carry pre-computed embeddings). Returns a MutationResult.
getIndex(_:)
IndexInfo. Throws if the index does not exist.
listIndexes()
IndexInfo.
refreshIndex(_:)
RefreshResult describing
whether an update was applied.
loadIndex(_:options:)
LoadIndexOptions. Throws if the index does not
exist or loading fails.
query(::options:)
loadIndex(_:options:) first; querying an index that has
not been loaded throws. Configure with QueryOptions
and read matches from the returned SearchResult.
unloadIndex(_:)
query(_:_:options:) calls for that index throw until it is
loaded again.
addDocs(_:docs:upsert:)
MutationResult.
getDocs(_:docIds:)
docIds to fetch specific
documents; omit it to fetch all of them. Returns an array of
DocumentInfo.
deleteDocs(_:docIds:)
MutationResult.
getJobStatus(_:)
MossSession.pushIndex. Poll until status is
ready. Returns a JobStatus.
deleteIndex(_:)
MossSession.pushIndex) and all its data. Returns
true if deleted.
onMemoryPressure(_:)
UIApplication.didReceiveMemoryWarningNotification. Returns the
number of indexes freed. See MemoryPressureLevel.