Creates dense and sparse ArcadeDB vector indexes and runs nearest-neighbor
searches. Combine dense, sparse, and full-text results with fuse/3.
Nearest-neighbour searches bind query vectors and options as SQL parameters. Index references are built from validated identifiers. Index metadata and fusion options that enter the statement are validated by shape or allowlist. Fused full-text searches use allowlist-validated RID literals for their candidate filter. Validation errors omit caller values.
Summary
Functions
Creates a dense LSM_VECTOR index (idempotent — IF NOT EXISTS). opts:
similarity (:cosine default | :dot_product | :euclidean), encoding
(:float32 | :int8), quantization (:none | :int8 | :binary | :product),
max_connections (default 16), beam_width (default 100). Unknown opt keys are
rejected value-free (the server silently accepts unknown METADATA keys).
Creates a dense vector index, raising on error.
Creates an LSM_SPARSE_VECTOR index over a (tokens, weights) property pair
with IF NOT EXISTS. Options are :dimensions (positive integer) and
:modifier (:none or :idf). ArcadeDB 26.11.1 verifies the existing index
kind, fields, and explicitly supplied metadata. A mismatch returns the
server error. Omitted options use server defaults on creation and impose
no metadata match on an existing index.
Creates a sparse vector index, raising on error.
Drops a dense vector index (idempotent — IF EXISTS).
Drops a dense vector index, raising on error.
Drops a sparse vector index (idempotent — IF EXISTS).
Drops a sparse vector index, raising on error.
Runs a hybrid fusion over heterogeneous neighbour subqueries. neighbor_specs is a
non-empty list whose elements may each take one of three shapes, every one built with
distinct indexed params
Runs a hybrid fusion, returning rows or raising.
Builds the ArcadeDB index reference "Type[property]", validating both identifiers.
Runs a dense nearest-neighbour search, returning rows ranked closest-first (each
carries the vertex's top-level fields plus distance). query_vector and k bind
as params. opts: ef_search (pos_integer), max_distance (number), filter
(non-empty list of #<bucket>:<pos> candidate RID strings — restricts the search to
that candidate set), group_by (property name to group results by; validated for
identifier shape), group_size (pos_integer — max results per group). All bind as
params inside the query-options object.
Runs a dense nearest-neighbour search, returning rows or raising.
Builds the sparse index ref "Type[tokens,weights]", validating all three identifiers.
Runs a sparse (learned-sparse / BM25-style) nearest-neighbour search over an
LSM_SPARSE_VECTOR index, returning rows ranked by a top-level score (higher = better;
there is no distance). query_tokens/query_weights/k bind as params. opts: filter
(candidate RID set), group_by, group_size — ef_search/max_distance are not accepted
(rejected client-side value-free). See create_sparse_index/5 for the index coverage caveat.
Runs a sparse nearest-neighbour search, returning rows or raising.
Types
@type fuse_spec() :: {String.t(), String.t(), [number()], pos_integer()} | {:sparse, String.t(), String.t(), String.t(), [integer()], [number()], pos_integer()} | {:fulltext, String.t(), String.t() | [String.t()], String.t(), pos_integer()}
Functions
@spec create_dense_index( Arcadic.Conn.t(), String.t(), String.t(), pos_integer(), keyword() ) :: :ok | {:error, atom() | Exception.t()}
Creates a dense LSM_VECTOR index (idempotent — IF NOT EXISTS). opts:
similarity (:cosine default | :dot_product | :euclidean), encoding
(:float32 | :int8), quantization (:none | :int8 | :binary | :product),
max_connections (default 16), beam_width (default 100). Unknown opt keys are
rejected value-free (the server silently accepts unknown METADATA keys).
@spec create_dense_index!( Arcadic.Conn.t(), String.t(), String.t(), pos_integer(), keyword() ) :: :ok
Creates a dense vector index, raising on error.
@spec create_sparse_index( Arcadic.Conn.t(), String.t(), String.t(), String.t(), keyword() ) :: :ok | {:error, atom() | Exception.t()}
Creates an LSM_SPARSE_VECTOR index over a (tokens, weights) property pair
with IF NOT EXISTS. Options are :dimensions (positive integer) and
:modifier (:none or :idf). ArcadeDB 26.11.1 verifies the existing index
kind, fields, and explicitly supplied metadata. A mismatch returns the
server error. Omitted options use server defaults on creation and impose
no metadata match on an existing index.
Check Compatibility for the backfill floor. On a server
without backfill, create the index before loading data or update existing
rows to index them. When the DDL reports pre-existing rows, Arcadic emits
[:arcadic, :vector, :sparse_index_preexisting].
@spec create_sparse_index!( Arcadic.Conn.t(), String.t(), String.t(), String.t(), keyword() ) :: :ok
Creates a sparse vector index, raising on error.
@spec drop_dense_index(Arcadic.Conn.t(), String.t(), String.t()) :: :ok | {:error, atom() | Exception.t()}
Drops a dense vector index (idempotent — IF EXISTS).
@spec drop_dense_index!(Arcadic.Conn.t(), String.t(), String.t()) :: :ok
Drops a dense vector index, raising on error.
@spec drop_sparse_index(Arcadic.Conn.t(), String.t(), String.t(), String.t()) :: :ok | {:error, atom() | Exception.t()}
Drops a sparse vector index (idempotent — IF EXISTS).
@spec drop_sparse_index!(Arcadic.Conn.t(), String.t(), String.t(), String.t()) :: :ok
Drops a sparse vector index, raising on error.
@spec fuse(Arcadic.Conn.t(), [fuse_spec()], keyword()) :: {:ok, [map()]} | {:error, atom() | Exception.t()}
Runs a hybrid fusion over heterogeneous neighbour subqueries. neighbor_specs is a
non-empty list whose elements may each take one of three shapes, every one built with
distinct indexed params:
{type, property, query_vector, k}— a densevector.neighborssubquery;{:sparse, type, tokens_property, weights_property, query_tokens, query_weights, k}— avector.sparseNeighborssubquery;{:fulltext, type, property_or_properties, query, k}— a full-textSEARCH_INDEX(...) = truesubquery bounded byLIMIT :k. Pass a single property or a non-empty list of distinct properties in the FULL_TEXT index's order, as inArcadic.FullText.search/5.
Each query vector, token list, weight list, and search string binds as a distinct SQL parameter. An unknown tag or wrong-arity tuple produces a value-free error.
opts: fusion (:rrf default | :dbsf | :linear), weights (list of numbers),
k (pos_integer), filter (non-empty list of #<bucket>:<pos> candidate RID strings —
a SHARED candidate set: the dense/sparse arms thread it as a {filter: :rids} function
option, while the full-text arm uses allowlist-validated @rid IN [...] literals),
group_by (property name to group by; validated for identifier shape),
group_size (pos_integer — max results per group). group_by/group_size apply to the
FUSED output (the outer fuse object); all bind as params.
Fused rows are ranked by ArcadeDB's fusion score (higher = better) rather than the
distance that neighbors/6 returns.
neighbor_specs and weights are trusted developer-supplied config: the emitted
statement grows linearly with their length (no cap), matching arcadic's
no-statement-size-limit posture elsewhere.
@spec fuse!(Arcadic.Conn.t(), [fuse_spec()], keyword()) :: [map()]
Runs a hybrid fusion, returning rows or raising.
Builds the ArcadeDB index reference "Type[property]", validating both identifiers.
@spec neighbors( Arcadic.Conn.t(), String.t(), String.t(), [number()], pos_integer(), keyword() ) :: {:ok, [map()]} | {:error, atom() | Exception.t()}
Runs a dense nearest-neighbour search, returning rows ranked closest-first (each
carries the vertex's top-level fields plus distance). query_vector and k bind
as params. opts: ef_search (pos_integer), max_distance (number), filter
(non-empty list of #<bucket>:<pos> candidate RID strings — restricts the search to
that candidate set), group_by (property name to group results by; validated for
identifier shape), group_size (pos_integer — max results per group). All bind as
params inside the query-options object.
distance (and therefore max_distance) semantics depend on the index's
similarity: COSINE yields 0..1 ascending (0 = identical); DOT_PRODUCT yields
NEGATIVE values (≈ -1 identical, less-negative = farther), so a small positive
max_distance filters nothing; EUCLIDEAN differs again. Choose thresholds per the
index's similarity.
@spec neighbors!( Arcadic.Conn.t(), String.t(), String.t(), [number()], pos_integer(), keyword() ) :: [ map() ]
Runs a dense nearest-neighbour search, returning rows or raising.
@spec sparse_index_ref(String.t(), String.t(), String.t()) :: {:ok, String.t()} | {:error, :invalid_identifier}
Builds the sparse index ref "Type[tokens,weights]", validating all three identifiers.
@spec sparse_neighbors( Arcadic.Conn.t(), String.t(), String.t(), String.t(), [integer()], [number()], pos_integer(), keyword() ) :: {:ok, [map()]} | {:error, atom() | Exception.t()}
Runs a sparse (learned-sparse / BM25-style) nearest-neighbour search over an
LSM_SPARSE_VECTOR index, returning rows ranked by a top-level score (higher = better;
there is no distance). query_tokens/query_weights/k bind as params. opts: filter
(candidate RID set), group_by, group_size — ef_search/max_distance are not accepted
(rejected client-side value-free). See create_sparse_index/5 for the index coverage caveat.
@spec sparse_neighbors!( Arcadic.Conn.t(), String.t(), String.t(), String.t(), [integer()], [number()], pos_integer(), keyword() ) :: [map()]
Runs a sparse nearest-neighbour search, returning rows or raising.