Use these steps to build search indexes and retrieve ranked results from
ArcadeDB. Run the examples on an HTTP connection with a Doc type and the
declared properties used in each example.
Rank text matches
Create a FULL_TEXT index over the string properties you want to search.
ArcadeDB indexes existing rows. When using Arcadic.FullText.search/5,
specify the indexed properties in index order. Use
Arcadic.FullText.search_fields/5 to search by field without an exact
index-name match.
:ok = Arcadic.FullText.create_index(conn, "Doc", ["title", "body"])
{:ok, matches} =
Arcadic.FullText.search(conn, "Doc", ["title", "body"], query, with_score: true)Use :with_score for the BM25 relevance score. Both search functions allow
a list of candidate RIDs through :filter. An empty list returns no hits
without a query.
Search dense and sparse embeddings
Create a dense index with the same dimension as the stored and query vectors.
With cosine distance, smaller is closer. Dot-product distance uses a different
scale, so choose :max_distance for the index's similarity metric.
:ok =
Arcadic.Vector.create_dense_index(conn, "Doc", "embedding", 1536, similarity: :cosine)
{:ok, matches} =
Arcadic.Vector.neighbors(conn, "Doc", "embedding", query_vector, 10, max_distance: 0.3)Use Arcadic.Vector.create_sparse_index/5 for paired token and weight
properties and Arcadic.Vector.sparse_neighbors/8 to query them. Create the
index before loading rows if your server cannot backfill it. See
Compatibility. Sparse rows carry a score
in place of a distance.
Combine retrieval methods
Use Arcadic.Vector.fuse/3 to combine dense, sparse, and full-text result
lists. Its score ranks higher values first. Vector builders support candidate
RIDs through :filter and result grouping through :group_by and
:group_size. See GraphRAG for a working
hybrid search with text and dense vectors.