Moss. Client
(moss v1.1.0)
Copy Markdown
High-level entry point for the moss Elixir SDK.
Counterpart to MossClient in the Python SDK.
Example:
{:ok, client} = Moss.Client.new("project-id", "project-key")
# Cloud CRUD
{:ok, result} = Moss.Client.create_index(client, "my-index", docs)
{:ok, info} = Moss.Client.get_index(client, "my-index")
# Load and query a cloud index locally
{:ok, _} = Moss.Client.load_index(client, "faq-index")
{:ok, results} = Moss.Client.query(client, "faq-index", "cancel")
# Session workflow with built-in embeddings
{:ok, session} = Moss.Client.session(client, "session-abc")
{:ok, {2, 0}} = Moss.Session.add_docs(session, docs)
{:ok, result} = Moss.Session.query(session, "billing issue")
{:ok, _} = Moss.Session.push_index(session)
# Custom models still use explicit embeddings
{:ok, custom_session} = Moss.Client.session(client, "custom-session", model_id: "custom")
{:ok, {1, 0}} = Moss.Session.add_docs(custom_session, docs)
{:ok, custom_result} = Moss.Session.query(custom_session, "billing issue", embedding: my_vec)
Summary
Functions
Add documents to an existing cloud index.
Create a cloud index with initial documents.
Create an index from raw files via the server-side parse pipeline.
Delete documents by IDs from a cloud index.
Delete a cloud index.
Get documents from a cloud index.
Get metadata for a cloud index.
Get metadata for a loaded index.
Poll the status of an async job.
Check if an index is loaded.
List all cloud indexes for this project.
Load a cloud index into memory.
Create a new Moss.Client.
Query a locally loaded index.
Force an immediate refresh of a loaded index from the cloud.
Create or resume a local session index.
Unload an index from memory.
Types
Functions
@spec add_docs(t(), String.t(), [Moss.DocumentInfo.t()], keyword()) :: {:ok, Moss.MutationResult.t()} | {:error, String.t()}
Add documents to an existing cloud index.
Options:
:upsert(boolean, default nil — use server default)
@spec create_index(t(), String.t(), [Moss.DocumentInfo.t()], String.t()) :: {:ok, Moss.MutationResult.t()} | {:error, String.t()}
Create a cloud index with initial documents.
@spec create_index_from_files( t(), String.t(), [map()], String.t(), map() | nil ) :: {:ok, Moss.MutationResult.t()} | {:error, String.t()}
Create an index from raw files via the server-side parse pipeline.
Each file in files is a map with all three keys required:
:path— filesystem path:name— filename sent to the server:content_type— MIME type
model_id defaults to "moss-minilm". Must be a built-in model.
"custom" is not supported because the parse pipeline generates embeddings server-side.
At most 20 files per call.
parse_options is an optional map controlling extraction. Omitted keys use
the server defaults:
:ocr_mode:"auto_ocr"or"full_ocr". Use"full_ocr"for scanned documents with no text layer.:segmentation_method:"smart_layout_detection"or"page_by_page":use_high_resolution: boolean, slower but better on dense tables:merge_tables: boolean, join tables split across a page break
Supported content types: "application/pdf" and the DOCX MIME
"application/vnd.openxmlformats-officedocument.wordprocessingml.document".
Example:
{:ok, result} = Moss.Client.create_index_from_files(
client,
"my-index",
[
%{
name: "report.pdf",
content_type: "application/pdf",
path: "/docs/report.pdf"
},
%{
name: "manual.docx",
content_type: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
path: "/docs/manual.docx"
}
],
"moss-minilm",
%{ocr_mode: "full_ocr"}
)
@spec delete_docs(t(), String.t(), [String.t()]) :: {:ok, Moss.MutationResult.t()} | {:error, String.t()}
Delete documents by IDs from a cloud index.
Delete a cloud index.
Get documents from a cloud index.
Options:
:doc_ids(list of strings) — if provided, only fetch those docs
Get metadata for a cloud index.
Get metadata for a loaded index.
Poll the status of an async job.
Check if an index is loaded.
List all cloud indexes for this project.
Load a cloud index into memory.
Options:
:auto_refresh(boolean, default false):polling_interval(integer seconds, default 600)
Returns {:ok, Moss.IndexInfo.t()} or {:error, reason}.
Create a new Moss.Client.
The index API URL is resolved from the MOSS_INDEX_URL environment variable
(falls back to the default cloud endpoint). No URL option is needed.
@spec query(t(), String.t(), String.t(), keyword()) :: {:ok, Moss.SearchResult.t()} | {:error, String.t()}
Query a locally loaded index.
For built-in models, the query is embedded automatically. For indexes created
with model_id: "custom", pass the query embedding via embedding: [...].
Options:
:top_k(integer, default 5):alpha(float, default 0.8):filter(map):embedding(list of floats, required formodel_id: "custom")
Returns {:ok, Moss.SearchResult.t()} or {:error, reason}.
Force an immediate refresh of a loaded index from the cloud.
@spec session(t(), String.t(), keyword()) :: {:ok, GenServer.server()} | {:error, String.t()}
Create or resume a local session index.
If a cloud index with index_name already exists, it is silently loaded
into the session. If not, the session starts empty.
Options:
:model_id(String.t(), default "moss-minilm"):server_name— GenServer name for the Session process
Returns {:ok, pid} on success.
Unload an index from memory.