client.session(name), then add,
query, and delete documents locally; embedding and search run on-device, with no network
call per operation. When you are done, push_index() persists the index to the cloud.
A session is represented by a SessionIndex.
Operations
add_docs(docs, options?)- embeds and indexes documents locally; returns(added, updated).query(text, options?)- semantic or hybrid search over the in-memory index; returns aSearchResult.get_docs(options?)/delete_docs(ids)- read and remove documents locally.push_index()- uploads the session to the cloud, creating or replacing the cloud index of the same name. No server-side re-embedding.
session(name) is create-or-resume: if a cloud index with that name already exists it is
loaded into the session (no re-embedding); otherwise the session starts empty. The API is the
same in both cases.
Example
Performance characteristics
- Operations run in-process: no network round trip, TLS, or serialization on the query path.
- Query text is embedded by a local model; with
model_id="custom"you supply the query vector viaQueryOptions.embeddinginstead. - Local queries typically complete in single-digit milliseconds, which suits short, frequent queries against a per-session or per-user working set.
Session vs. loaded cloud index
| Use a session when | Use a loaded cloud index when |
|---|---|
| You are indexing data created at runtime (a live call, a chat, a working set) | You are querying a large, stable corpus built ahead of time |
| You need writes and reads against the same in-memory index | Reads dominate and the data changes infrequently |
| The data is per-conversation or per-user and short-lived | The index is shared across many sessions |
Related
Sessions guide
The full session lifecycle and API.
SessionIndex reference
Methods, parameters, and return types.