MossCore.Nif (moss_core v0.19.0)

Copy Markdown

Rustler NIF declarations for the moss library.

All functions raise :not_loaded if the NIF is not compiled. Functions that can fail return {:ok, result} or {:error, reason}.

Summary

Functions

Add docs to a cloud index. Returns {:ok, MutationResult} or {:error, reason}.

Create an index in the cloud. Returns {:ok, MutationResult} or {:error, reason}.

Create an index from files via the parse pipeline. Returns {:ok, MutationResult} or {:error, reason}.

Delete docs from a cloud index. Returns {:ok, MutationResult} or {:error, reason}.

Delete a cloud index. Returns {:ok, bool} or {:error, reason}.

Get docs from a cloud index. Returns {:ok, [DocumentInfo]} or {:error, reason}.

Get a cloud index's metadata. Returns {:ok, IndexInfo} or {:error, reason}.

Get job status. Returns {:ok, JobStatusResponse} or {:error, reason}.

List all cloud indexes. Returns {:ok, [IndexInfo]} or {:error, reason}.

Create a new ManageClient resource. Returns {:ok, ref} or {:error, reason}.

Validate project credentials. Returns {:ok, CredentialsInfo} or {:error, reason}.

Current {device_id, moss_device_id} pair of an IndexManager.

Get index metadata. Returns {:ok, IndexInfo} or {:error, reason}.

Check if an index is loaded. Returns boolean.

Load an index from cloud. Returns {:ok, IndexInfo} or {:error, reason}.

Bulk-load indexes. Returns %Moss.LoadIndexesResult{loaded: [...], failed: %{name => reason}}.

Preload the built-in embedding model for a loaded index.

Create a new IndexManager resource. Returns {:ok, ref} or {:error, reason}.

Query a loaded index. Returns {:ok, SearchResult} or {:error, reason}.

Multi-index query with a caller-supplied embedding. Returns {:ok, SearchResult} or {:error, reason}.

Multi-index query where the core embeds the text. Returns {:ok, SearchResult} or {:error, reason}.

Query a loaded index using built-in embeddings from the query text.

Force refresh an index from cloud. Returns {:ok, RefreshResult} or {:error, reason}.

Set the stable per-device id on an IndexManager; nil keeps the current id. Returns :ok.

Unload an index. Returns {:ok, :ok} or {:error, reason}.

Bulk-unload indexes; names that are not loaded are ignored. Returns :ok.

Add documents to a SessionIndex. Returns {:ok, {added, updated}} or {:error, reason}.

Add documents to a SessionIndex using built-in embeddings from document text.

Delete documents from a SessionIndex by IDs. Returns count deleted.

Get the document count of a SessionIndex.

Get documents from a SessionIndex. doc_ids may be nil for all docs.

Load an existing cloud index into the session. Returns {:ok, doc_count} or {:error, reason}.

Load a cloud index into the session with auto-refresh options.

Preload the built-in embedding model for a SessionIndex.

Get the name of a SessionIndex.

Push the session index to the cloud. Returns {:ok, PushIndexResult} or {:error, reason}.

Query a SessionIndex. Returns {:ok, SearchResult} or {:error, reason}.

Query a SessionIndex using built-in embeddings from the query text.

Set the stable per-device id on a SessionIndex; nil keeps the current id. Returns :ok.

Override a SessionIndex's device ids when given (nil keeps them) and replace its user id (nil clears it). Returns :ok.

Functions

manage_add_docs(ref, name, docs, upsert)

Add docs to a cloud index. Returns {:ok, MutationResult} or {:error, reason}.

manage_create_index(ref, name, docs, model_id)

Create an index in the cloud. Returns {:ok, MutationResult} or {:error, reason}.

manage_create_index_from_files(ref, name, files, model_id)

Create an index from files via the parse pipeline. Returns {:ok, MutationResult} or {:error, reason}.

manage_create_index_from_files(ref, name, files, model_id, parse_options)

manage_delete_docs(ref, name, doc_ids)

Delete docs from a cloud index. Returns {:ok, MutationResult} or {:error, reason}.

manage_delete_index(ref, name)

Delete a cloud index. Returns {:ok, bool} or {:error, reason}.

manage_get_docs(ref, name, doc_ids)

Get docs from a cloud index. Returns {:ok, [DocumentInfo]} or {:error, reason}.

manage_get_index(ref, name)

Get a cloud index's metadata. Returns {:ok, IndexInfo} or {:error, reason}.

manage_get_job_status(ref, job_id)

Get job status. Returns {:ok, JobStatusResponse} or {:error, reason}.

manage_list_indexes(ref)

List all cloud indexes. Returns {:ok, [IndexInfo]} or {:error, reason}.

manage_new(project_id, project_key, base_url, client_id)

Create a new ManageClient resource. Returns {:ok, ref} or {:error, reason}.

manage_validate_credentials(ref)

Validate project credentials. Returns {:ok, CredentialsInfo} or {:error, reason}.

manager_device_identity(ref)

Current {device_id, moss_device_id} pair of an IndexManager.

manager_get_index_info(ref, index_name)

Get index metadata. Returns {:ok, IndexInfo} or {:error, reason}.

manager_has_index(ref, index_name)

Check if an index is loaded. Returns boolean.

manager_load_index(ref, index_name, auto_refresh, polling_interval)

manager_load_index(ref, index_name, auto_refresh, polling_interval, cache_path)

Load an index from cloud. Returns {:ok, IndexInfo} or {:error, reason}.

manager_load_indexes(ref, index_names, auto_refresh, polling_interval)

Bulk-load indexes. Returns %Moss.LoadIndexesResult{loaded: [...], failed: %{name => reason}}.

manager_load_query_model(ref, index_name)

Preload the built-in embedding model for a loaded index.

manager_new(project_id, project_key, base_url, client_id)

Create a new IndexManager resource. Returns {:ok, ref} or {:error, reason}.

manager_query(ref, index_name, query, embedding, top_k, alpha, filter)

Query a loaded index. Returns {:ok, SearchResult} or {:error, reason}.

manager_query_multi_index(ref, index_names, query, embedding, top_k, alpha, filter)

Multi-index query with a caller-supplied embedding. Returns {:ok, SearchResult} or {:error, reason}.

manager_query_multi_index_text(ref, index_names, query, top_k, alpha, filter)

Multi-index query where the core embeds the text. Returns {:ok, SearchResult} or {:error, reason}.

manager_query_text(ref, index_name, query, top_k, alpha, filter)

Query a loaded index using built-in embeddings from the query text.

manager_refresh_index(ref, index_name)

Force refresh an index from cloud. Returns {:ok, RefreshResult} or {:error, reason}.

manager_set_device_id(ref, device_id)

Set the stable per-device id on an IndexManager; nil keeps the current id. Returns :ok.

manager_unload_index(ref, index_name)

Unload an index. Returns {:ok, :ok} or {:error, reason}.

manager_unload_indexes(ref, index_names)

Bulk-unload indexes; names that are not loaded are ignored. Returns :ok.

session_add_docs(ref, docs, embeddings, upsert)

Add documents to a SessionIndex. Returns {:ok, {added, updated}} or {:error, reason}.

session_add_docs_text(ref, docs, upsert)

Add documents to a SessionIndex using built-in embeddings from document text.

session_delete_docs(ref, doc_ids)

Delete documents from a SessionIndex by IDs. Returns count deleted.

session_doc_count(ref)

Get the document count of a SessionIndex.

session_get_docs(ref, doc_ids)

Get documents from a SessionIndex. doc_ids may be nil for all docs.

session_load_index(ref, index_name)

Load an existing cloud index into the session. Returns {:ok, doc_count} or {:error, reason}.

session_load_index_with_options(ref, index_name, auto_refresh, polling_interval_in_seconds)

Load a cloud index into the session with auto-refresh options.

When auto_refresh is true, a background task polls the cloud index every polling_interval_in_seconds and pulls newer versions in on the next session_query/session_get_docs/session_doc_count. Auto-refresh pauses while the session has un-pushed local edits, so it never clobbers local work. Returns {:ok, doc_count} or {:error, reason}.

session_load_model(ref)

Preload the built-in embedding model for a SessionIndex.

session_name(ref)

Get the name of a SessionIndex.

session_new(name, model_id, project_id, project_key, client_id)

Create a new SessionIndex resource.

session_push_index(ref)

Push the session index to the cloud. Returns {:ok, PushIndexResult} or {:error, reason}.

session_query(ref, query, top_k, embedding, alpha, filter)

Query a SessionIndex. Returns {:ok, SearchResult} or {:error, reason}.

session_query_text(ref, query, top_k, alpha, filter)

Query a SessionIndex using built-in embeddings from the query text.

session_set_device_id(ref, device_id)

Set the stable per-device id on a SessionIndex; nil keeps the current id. Returns :ok.

session_set_identity(ref, device_id, user_id, moss_device_id)

Override a SessionIndex's device ids when given (nil keeps them) and replace its user id (nil clears it). Returns :ok.