(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.
(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.
(get-item idx id)Returns {:id .. :vector float[] .. :metadata ..} for id, or nil.
Returns {:id .. :vector float[] .. :metadata ..} for id, or nil.
(index opts)Creates an embedded HNSW vector index handle.
:ef trades recall for speed during search; higher values improve recall.
Creates an embedded HNSW vector index handle. :ef trades recall for speed during search; higher values improve recall.
(load-index path)Loads an index handle from path, a directory containing index.bin and meta.edn.
Loads an index handle from path, a directory containing index.bin and meta.edn.
(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.
(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.
(search idx query-vec k)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.
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.
(size idx)Returns the number of indexed items.
Returns the number of indexed items.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |