Skip to main content
Swift SDK / Types Reference for the structs and enums passed to and returned from MossClient and MossSession.

DocumentInfo

A document stored in or returned from an index. Conforms to Codable.
public struct DocumentInfo: Codable {
    public let id: String
    public let text: String
    public let metadata: [String: String]?   // optional, defaults to nil
    public let embedding: [Float]?            // optional, defaults to nil
}
FieldTypeDescription
idStringUnique document id.
textStringDocument text.
metadata[String: String]?Optional string key/value metadata, usable in filters.
embedding[Float]?Optional pre-computed embedding. Required when the session/index uses the "custom" model.

QueryOptions

public struct QueryOptions {
    public var topK: Int        // default 5
    public var alpha: Float     // default 0.8
    public var filterJson: String?
}
FieldTypeDescription
topKIntNumber of results to return. Default 5.
alphaFloatHybrid blend: 1.0 = pure semantic, 0.0 = pure keyword. Default 0.8 (semantic-heavy).
filterJsonString?Optional metadata filter as a JSON string ($eq, $and, $in, $near, …).
See Querying for hybrid-search and metadata-filtering examples.

SearchResult

Returned by query(...).
public struct SearchResult {
    public let docs: [QueryResult]
    public let query: String
    public let timeMs: UInt64
}

QueryResult

A single match within a SearchResult.
public struct QueryResult {
    public let id: String
    public let score: Float
    public let text: String
    public let metadata: [String: String]?
}

ModelRef

Reference to an embedding model with version information. Surfaced on IndexInfo.
public struct ModelRef {
    public let id: String
    public let version: String?
}
FieldTypeDescription
idStringModel identifier.
versionString?Model version (semver or build identifier).

IndexInfo

Metadata about a cloud index. Returned by getIndex and listIndexes.
public struct IndexInfo {
    public let id: String
    public let name: String
    public let status: String
    public let docCount: Int
    public let model: ModelRef
    public let version: String?
    public let createdAt: String?
    public let updatedAt: String?
}
FieldTypeDescription
idStringUnique identifier of the index.
nameStringHuman-readable name of the index.
statusStringCurrent build status (e.g. NotStarted, Building, Ready, Failed).
docCountIntNumber of documents in the index.
modelModelRefEmbedding model bound to the index.
versionString?Index build/format version.
createdAtString?When the index was created.
updatedAtString?When the index was last updated.

SessionOptions

Passed to MossClient.session(_:options:).
public struct SessionOptions {
    public var modelId: String?    // optional, defaults to nil
}
FieldTypeDescription
modelIdString?Embedding model id. nil = platform default (moss-litelm on iOS). Pass "custom" to supply embeddings via DocumentInfo.embedding.

PushIndexResult

Returned by MossSession.pushIndex(). Poll jobId with getJobStatus until status is ready.
public struct PushIndexResult {
    public let jobId: String
    public let indexName: String
    public let docCount: Int
    public let status: String
}

MutationResult

Returned by the cloud document operations createIndex, addDocs, and deleteDocs after the operation completes.
public struct MutationResult {
    public let jobId: String
    public let indexName: String
    public let docCount: Int
}
FieldTypeDescription
jobIdStringIdentifier of the async job that performed the mutation.
indexNameStringName of the index that was mutated.
docCountIntNumber of documents in the index after the mutation.

RefreshResult

Returned by refreshIndex.
public struct RefreshResult {
    public let indexName: String
    public let previousUpdatedAt: String
    public let newUpdatedAt: String
    public let wasUpdated: Bool
}
FieldTypeDescription
indexNameStringName of the index that was refreshed.
previousUpdatedAtStringTimestamp before the refresh.
newUpdatedAtStringTimestamp after the refresh.
wasUpdatedBooltrue when a newer cloud version was applied.

JobStatus

Returned by getJobStatus.
public struct JobStatus {
    public let jobId: String
    public let status: String
    public let progress: Double
    public let currentPhase: String?
    public let error: String?
    public let createdAt: String
    public let updatedAt: String
    public let completedAt: String?
}

MemoryPressureLevel

Passed to onMemoryPressure.
public enum MemoryPressureLevel: UInt8 {
    case low = 0        // hint: drop hot caches
    case critical = 1   // drop everything reclaimable; on-disk caches kept
}

MossError

Thrown for any failure reported by the underlying runtime. Conforms to LocalizedError, so error.localizedDescription returns the message.
public struct MossError: LocalizedError {
    public let code: Int32
    public let message: String
}