PaveDBClient.Collection (pavedb_client v0.2.0)

Copy Markdown

Tenant-scoped collection handle.

Every function here forwards to its PaveDBClient counterpart with the tenant and collection the handle already carries. Build one with PaveDBClient.collection/3 or PaveDBClient.create_collection/3.

Summary

Functions

Adds one raw text document. Takes :docid and :metadata.

Adds several documents in one request.

Adds one precomputed embedding. Takes :docid and :metadata.

Cancels a reindex job.

Deletes one document by id, along with its chunks.

Fetches the collection's settings plus document and chunk counts.

Downloads this collection as a binary zip archive.

Fetches one document by id, with its metadata and chunk ids.

Fetches one chunk's record by its rid.

Fetches one chunk's raw text as %{"content" => text, "content_type" => type}.

Fetches one logged search, including the result ids it returned.

Fetches a reindex job's status.

Uploads a local file. Takes :docid, :metadata, :content_type, and :csv_options.

Lists the chunks a document was split into. Listings carry no chunk text.

Lists the collection's documents.

Lists logged searches, newest first. Takes :limit and :offset.

Searches and returns just the matches, skipping the response envelope.

Renames the collection and returns a handle pointing at the new slug.

Replays one logged search against the collection's current data.

Restores a binary zip archive into this collection's name.

Searches by text and returns the full response envelope.

Searches with a precomputed query vector. Takes the same options as search/3.

Starts a resumable reindex. Takes :embedder_type, :embed_model, and :embedder_config.

Updates editable metadata. Takes :display_name.

Types

t()

@type t() :: %PaveDBClient.Collection{
  client: PaveDBClient.Client.t(),
  name: String.t(),
  tenant: String.t()
}

Functions

add(collection, text, opts \\ [])

@spec add(t(), String.t(), keyword()) ::
  {:ok, map()} | {:error, PaveDBClient.Error.t()}

Adds one raw text document. Takes :docid and :metadata.

add_many(collection, documents)

@spec add_many(t(), list()) :: {:ok, map()} | {:error, PaveDBClient.Error.t()}

Adds several documents in one request.

The response reports per-document results, so a {:ok, _} can still carry individual failures under "documents".

add_vector(collection, vector, opts \\ [])

@spec add_vector(t(), [number()], keyword()) ::
  {:ok, map()} | {:error, PaveDBClient.Error.t()}

Adds one precomputed embedding. Takes :docid and :metadata.

cancel_reindex(collection, job_id)

@spec cancel_reindex(t(), String.t()) ::
  {:ok, map()} | {:error, PaveDBClient.Error.t()}

Cancels a reindex job.

delete(collection, docid)

@spec delete(t(), String.t()) :: {:ok, map()} | {:error, PaveDBClient.Error.t()}

Deletes one document by id, along with its chunks.

detail(collection)

@spec detail(t()) :: {:ok, map()} | {:error, PaveDBClient.Error.t()}

Fetches the collection's settings plus document and chunk counts.

export_archive(collection)

@spec export_archive(t()) :: {:ok, binary()} | {:error, PaveDBClient.Error.t()}

Downloads this collection as a binary zip archive.

get(collection, docid)

@spec get(t(), String.t()) :: {:ok, map()} | {:error, PaveDBClient.Error.t()}

Fetches one document by id, with its metadata and chunk ids.

get_chunk(collection, rid)

@spec get_chunk(t(), String.t()) :: {:ok, map()} | {:error, PaveDBClient.Error.t()}

Fetches one chunk's record by its rid.

get_chunk_content(collection, rid)

@spec get_chunk_content(t(), String.t()) ::
  {:ok, map()} | {:error, PaveDBClient.Error.t()}

Fetches one chunk's raw text as %{"content" => text, "content_type" => type}.

get_query(collection, query_id)

@spec get_query(t(), String.t()) :: {:ok, map()} | {:error, PaveDBClient.Error.t()}

Fetches one logged search, including the result ids it returned.

get_reindex(collection, job_id)

@spec get_reindex(t(), String.t()) :: {:ok, map()} | {:error, PaveDBClient.Error.t()}

Fetches a reindex job's status.

ingest(collection, path, opts \\ [])

@spec ingest(t(), Path.t(), keyword()) ::
  {:ok, map()} | {:error, PaveDBClient.Error.t()}

Uploads a local file. Takes :docid, :metadata, :content_type, and :csv_options.

list_chunks(collection, docid)

@spec list_chunks(t(), String.t()) :: {:ok, map()} | {:error, PaveDBClient.Error.t()}

Lists the chunks a document was split into. Listings carry no chunk text.

list_documents(collection)

@spec list_documents(t()) :: {:ok, [map()]} | {:error, PaveDBClient.Error.t()}

Lists the collection's documents.

list_queries(collection, opts \\ [])

@spec list_queries(
  t(),
  keyword()
) :: {:ok, map()} | {:error, PaveDBClient.Error.t()}

Lists logged searches, newest first. Takes :limit and :offset.

matches(collection, q, opts \\ [])

@spec matches(t(), String.t(), keyword()) ::
  {:ok, [map()]} | {:error, PaveDBClient.Error.t()}

Searches and returns just the matches, skipping the response envelope.

rename(collection, new_name)

@spec rename(t(), String.t()) :: {:ok, t()} | {:error, PaveDBClient.Error.t()}

Renames the collection and returns a handle pointing at the new slug.

The original handle still carries the old name, so keep the returned one.

replay_query(collection, query_id)

@spec replay_query(t(), String.t()) :: {:ok, map()} | {:error, PaveDBClient.Error.t()}

Replays one logged search against the collection's current data.

Compare the replayed ids with the stored ones to detect drift.

restore_archive(collection, archive, opts \\ [])

@spec restore_archive(t(), binary(), keyword()) ::
  {:ok, map()} | {:error, PaveDBClient.Error.t()}

Restores a binary zip archive into this collection's name.

Creates a new collection by default; pass replace: true to replace one.

search(collection, q, opts \\ [])

@spec search(t(), String.t(), keyword()) ::
  {:ok, map()} | {:error, PaveDBClient.Error.t()}

Searches by text and returns the full response envelope.

Takes :k, :filters, :content_filter, :mode, and :include_common. Use matches/3 for the hits alone.

search_vector(collection, vector, opts \\ [])

@spec search_vector(t(), [number()], keyword()) ::
  {:ok, map()} | {:error, PaveDBClient.Error.t()}

Searches with a precomputed query vector. Takes the same options as search/3.

start_reindex(collection, opts \\ [])

@spec start_reindex(
  t(),
  keyword()
) :: {:ok, map()} | {:error, PaveDBClient.Error.t()}

Starts a resumable reindex. Takes :embedder_type, :embed_model, and :embedder_config.

update(collection, opts \\ [])

@spec update(
  t(),
  keyword()
) :: {:ok, map()} | {:error, PaveDBClient.Error.t()}

Updates editable metadata. Takes :display_name.