Liking cljdoc? Tell your friends :D

vector-search.core


add!clj

(add! idx id v)
(add! idx id v metadata)

Adds or replaces id with vector v. Metadata is stored outside hnswlib.

Adds or replaces id with vector v. Metadata is stored outside hnswlib.
sourceraw docstring

add-batch!clj

(add-batch! idx items)

Adds each {:id .. :vector .. :metadata ..} item and returns the count added.

Adds each {:id .. :vector .. :metadata ..} item and returns the count added.
sourceraw docstring

get-itemclj

(get-item idx id)

Returns {:id .. :vector float[] .. :metadata ..} for id, or nil.

Returns {:id .. :vector float[] .. :metadata ..} for id, or nil.
sourceraw docstring

indexclj

(index opts)

Creates an embedded vector index handle.

:type is :hnsw by default. :exact uses exhaustive exact search, O(n) per query, with no tuning knobs; it is useful as ground truth or for small corpora. :ef trades recall for speed during search; higher values improve recall.

Creates an embedded vector index handle.

:type is :hnsw by default. :exact uses exhaustive exact search, O(n) per
query, with no tuning knobs; it is useful as ground truth or for small
corpora.
:ef trades recall for speed during search; higher values improve recall.
sourceraw docstring

load-indexclj

(load-index path)

Loads an index handle from path, a directory containing index.bin and meta.edn.

:type in meta.edn selects :hnsw or :exact. Legacy saves without :type load as :hnsw. :exact uses exhaustive exact search, O(n) per query, with no tuning knobs; it is useful as ground truth or for small corpora.

Loads an index handle from path, a directory containing index.bin and meta.edn.

:type in meta.edn selects :hnsw or :exact. Legacy saves without :type load as
:hnsw. :exact uses exhaustive exact search, O(n) per query, with no tuning
knobs; it is useful as ground truth or for small corpora.
sourceraw docstring

remove!clj

(remove! idx id)

Removes id from the index. Returns true when an item was removed.

Removes id from the index. Returns true when an item was removed.
sourceraw docstring

saveclj

(save idx path)

Persists idx into path, a directory created when absent. Returns path.

Persists idx into path, a directory created when absent. Returns path.
sourceraw docstring

(search idx query-vec k)
(search idx query-vec k {:keys [filter] :as opts})

Returns nearest results best-first.

For :cosine and :dot, :score is a similarity where higher is better. For :euclidean, :score is L2 distance where lower is better.

With opts, :filter is a predicate over the result map ({:id .. :score .. :metadata ..}); only results satisfying it are returned, still k best-first. Filtering is implemented by over-fetching candidates from the index and growing the candidate set (doubling, up to the full index) until k matches are found, so a highly selective filter on a large index costs proportionally more. Exact indexes fetch the full index size when filtering because exact search is already exhaustive.

Returns nearest results best-first.

For :cosine and :dot, :score is a similarity where higher is better. For
:euclidean, :score is L2 distance where lower is better.

With opts, `:filter` is a predicate over the result map
(`{:id .. :score .. :metadata ..}`); only results satisfying it are
returned, still k best-first. Filtering is implemented by over-fetching
candidates from the index and growing the candidate set (doubling, up to
the full index) until k matches are found, so a highly selective filter
on a large index costs proportionally more. Exact indexes fetch the full
index size when filtering because exact search is already exhaustive.
sourceraw docstring

sizeclj

(size idx)

Returns the number of indexed items.

Returns the number of indexed items.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close