PaveDBClient (pavedb_client v0.1.0)

Copy Markdown

Elixir client for PaveDB's HTTP API.

Summary

Functions

Adds several raw text documents to a collection.

Adds one raw text document to a collection.

Adds one precomputed embedding to a collection.

Builds a tenant-scoped collection handle without making a request.

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

Builds a client for a running PaveDB HTTP server.

Creates a collection and returns a collection handle.

Creates or configures a tenant collection.

Deletes a collection and every document in it.

Formats a structured client error for logs or operator messages.

Fetches one chunk by its record id.

Fetches one chunk's raw text content.

Fetches one logged search, including its original result ids.

Checks server health through the root /health endpoint.

Uploads a local file to a collection.

Lists the chunks a document was split into.

Lists a tenant's collections.

Lists documents in a collection.

Lists logged searches for a collection, newest first.

Renames a collection, changing its slug and URL.

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

Searches a collection and returns the full PaveDB response envelope.

Searches the one collection PaveDB is configured to share across tenants.

Searches a collection with a precomputed query vector.

Updates a collection's editable metadata (currently display_name).

Returns the package version.

Functions

add_many(client, tenant, collection, documents)

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

Adds several raw text documents to a collection.

Each item may be a string, a map with text or vector plus docid and metadata, or {text, docid, metadata}.

add_text(client, tenant, collection, text, opts \\ [])

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

Adds one raw text document to a collection.

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

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

Adds one precomputed embedding to a collection.

PaveDB takes either text or a raw vector, never both.

collection(client, name, opts \\ [])

Builds a tenant-scoped collection handle without making a request.

collection_detail(client, tenant, name)

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

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

connect(base_url \\ nil, opts \\ [])

@spec connect(
  String.t() | nil,
  keyword()
) :: PaveDBClient.Client.t()

Builds a client for a running PaveDB HTTP server.

The base URL falls back to PAVEDB_URL, then to http://localhost:8086. See PaveDBClient.Client.new/2 for the options.

create_collection(client, name, opts \\ [])

@spec create_collection(PaveDBClient.Client.t(), String.t(), keyword()) ::
  {:ok, PaveDBClient.Collection.t()} | {:error, PaveDBClient.Error.t()}

Creates a collection and returns a collection handle.

create_collection(client, tenant, name, attrs)

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

Creates or configures a tenant collection.

delete_collection(client, tenant, name)

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

Deletes a collection and every document in it.

delete_document(client, tenant, collection, docid)

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

Deletes one document by id.

format_error(other)

@spec format_error(PaveDBClient.Error.t() | term()) :: String.t()

Formats a structured client error for logs or operator messages.

get_chunk(client, tenant, collection, rid)

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

Fetches one chunk by its record id.

get_chunk_content(client, tenant, collection, rid)

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

Fetches one chunk's raw text content.

Returns %{"content" => body, "content_type" => type}; the endpoint answers with the raw body rather than a JSON envelope.

get_document(client, tenant, collection, docid)

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

Fetches one document by id.

get_query(client, tenant, collection, query_id)

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

Fetches one logged search, including its original result ids.

health(client)

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

Checks server health through the root /health endpoint.

/health lives outside the /v1 API and needs no auth, so it doubles as a basic connection check. Returns the readiness envelope (status, version).

ingest_file(client, tenant, collection, path, opts \\ [])

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

Uploads a local file to a collection.

list_chunks(client, tenant, collection, docid)

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

Lists the chunks a document was split into.

list_collections(client, opts \\ [])

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

Lists a tenant's collections.

list_documents(client, tenant, collection)

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

Lists documents in a collection.

list_queries(client, tenant, collection, opts \\ [])

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

Lists logged searches for a collection, newest first.

move_collection(client, tenant, name, new_name)

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

Renames a collection, changing its slug and URL.

new(base_url \\ nil, opts \\ [])

@spec new(
  String.t() | nil,
  keyword()
) :: PaveDBClient.Client.t()

Alias for connect/2.

replay_query(client, tenant, collection, query_id)

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

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

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

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

Searches a collection and returns the full PaveDB response envelope.

search_shared(client, q, opts \\ [])

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

Searches the one collection PaveDB is configured to share across tenants.

Takes :k and :filters. The endpoint needs no tenant or collection, and answers with an empty match list when the server has no shared scope enabled. There is no raw-vector form: the server drops v on this endpoint, so only text queries reach it.

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

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

Searches a collection with a precomputed query vector.

PaveDB takes either a text query or a raw vector, never both.

update_collection(client, tenant, name, opts \\ [])

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

Updates a collection's editable metadata (currently display_name).

version()

@spec version() :: String.t()

Returns the package version.