RuvectorElixir.VectorEntry (ruvector_elixir v0.1.0)

Copy Markdown View Source

Represents a vector entry stored in or retrieved from a Ruvector database.

An entry consists of:

  • id: Optional unique string identifier (auto-generated UUID if omitted upon insert).
  • vector: List of 32-bit floating point numbers representing the vector embedding.
  • metadata: Optional arbitrary map of JSON-serializable key-value metadata.

Summary

Functions

Converts a map returned by RuvectorElixir.get/2 or RuvectorElixir.get_entry/2 into a VectorEntry struct.

Creates a new VectorEntry struct.

Types

t()

@type t() :: %RuvectorElixir.VectorEntry{
  id: String.t() | nil,
  metadata: map() | nil,
  vector: [float()]
}

Functions

from_map(map)

@spec from_map(map()) :: t()

Converts a map returned by RuvectorElixir.get/2 or RuvectorElixir.get_entry/2 into a VectorEntry struct.

Examples

iex> map = %{id: "doc_1", vector: [0.1, 0.2], metadata: %{"tag" => "A"}}
iex> RuvectorElixir.VectorEntry.from_map(map)
%RuvectorElixir.VectorEntry{id: "doc_1", vector: [0.1, 0.2], metadata: %{"tag" => "A"}}

new(vector, opts \\ [])

@spec new([number()], keyword() | map()) :: t()

Creates a new VectorEntry struct.

Accepts vectors with float or integer components (automatically converted to floats).

Options

  • :id - Unique string identifier (or atom / integer).
  • :metadata - Map of metadata attributes.

Examples

iex> RuvectorElixir.VectorEntry.new([1.0, 2.0, 3.0])
%RuvectorElixir.VectorEntry{id: nil, vector: [1.0, 2.0, 3.0], metadata: nil}

iex> RuvectorElixir.VectorEntry.new([1, 2, 3], id: "vec_1", metadata: %{"label" => "sample"})
%RuvectorElixir.VectorEntry{id: "vec_1", vector: [1.0, 2.0, 3.0], metadata: %{"label" => "sample"}}