SessionIndex, created from
client.session(). It requires a client built with a
projectKey; calling session() on a client built with a custom authenticator throws.
Create or resume
client.session(name) returns a SessionIndex. If a cloud index with that name already
exists it auto-loads into the session (no re-embedding); otherwise the session starts empty.
The workflow is identical in both cases, and name is also the target when
pushIndex() is called.
Short-term vs. long-term context
A session is short-term context - the working set for the current interaction. A persistent cloud index loaded withclient.loadIndex() is long-term
context - durable knowledge shared across interactions. Most real-time apps query both: load
a cloud index for long-term knowledge, open a session for the live turns, and query each.
Loading a cloud index into a session
A session can also pull an existing cloud index into its local store withloadIndex(). With autoRefresh: true the SDK polls the
cloud and pulls newer versions in on subsequent reads (paused while the session has un-pushed
local edits).
Behavior notes
- Every session operation (
addDocs,deleteDocs,getDocs,query) runs in process memory with no per-operation cloud round trip. - The embedding model is set by the optional second argument to
session()(default"moss-minilm"; also"moss-mediumlm"or"custom"). When resuming an existing cloud index, omit the model to adopt the stored one - all participants resuming the same index must use the same model. - With
modelId: 'custom', each added document must carry anembeddingand everyquerymust pass anembedding. See Custom embeddings. pushIndex()uploads documents with their locally-computed embeddings; no server-side re-embedding occurs.
Related
- SessionIndex reference - every session method.
- MossClient.session() - open or resume a session.
- Metadata filtering - filter inside a session query.
- SDK reference - the full JavaScript SDK overview.