{"id":13531712,"url":"https://github.com/zhao-lang/redis_hnsw","last_synced_at":"2026-03-11T23:39:04.446Z","repository":{"id":85278621,"uuid":"246680661","full_name":"zhao-lang/redis_hnsw","owner":"zhao-lang","description":"HSNW module for Redis","archived":false,"fork":false,"pushed_at":"2020-09-01T23:57:31.000Z","size":152,"stargazers_count":57,"open_issues_count":4,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-17T02:36:58.521Z","etag":null,"topics":["approximate-nearest-neighbor-search","hnsw","knn","redis","redis-module","rust"],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zhao-lang.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2020-03-11T21:10:21.000Z","updated_at":"2024-08-13T14:22:36.000Z","dependencies_parsed_at":null,"dependency_job_id":"22c907d8-9ca7-492e-aa17-484e8dff3700","html_url":"https://github.com/zhao-lang/redis_hnsw","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhao-lang%2Fredis_hnsw","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhao-lang%2Fredis_hnsw/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhao-lang%2Fredis_hnsw/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhao-lang%2Fredis_hnsw/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zhao-lang","download_url":"https://codeload.github.com/zhao-lang/redis_hnsw/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246709921,"owners_count":20821296,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["approximate-nearest-neighbor-search","hnsw","knn","redis","redis-module","rust"],"created_at":"2024-08-01T07:01:05.069Z","updated_at":"2026-03-11T23:39:04.396Z","avatar_url":"https://github.com/zhao-lang.png","language":"Rust","funding_links":[],"categories":["Libraries and Tools","Awesome Vector Search Engine"],"sub_categories":["2023","Standalone Service"],"readme":"[![licence](https://img.shields.io/github/license/zhao-lang/redis_hnsw.svg)](https://github.com/zhao-lang/redis_hnsw/blob/master/LICENSE)\n[![release](https://img.shields.io/github/v/release/zhao-lang/redis_hnsw.svg)](https://github.com/zhao-lang/redis_hnsw/releases/latest)\n[![rust](https://github.com/zhao-lang/redis_hnsw/workflows/Rust/badge.svg)](https://github.com/zhao-lang/redis_hnsw/actions?query=workflow%3ARust)\n\n# HNSW for Redis\n\u003ca id=\"markdown-hnsw-for-redis\" name=\"hnsw-for-redis\"\u003e\u003c/a\u003e\n\n`redis_hnsw` is a Hierarchical Navigable Small World (HNSW) implementation for Redis. Based on the paper [Efficient and robust approximate nearest neighbor search using Hierarchical Navigable Small World graphs](https://arxiv.org/abs/1603.09320). Currently only supports Euclidean distance, Hamming distance forthcoming.\n\n\u003c!-- TOC --\u003e\n## Table of Contents\n\n- [Getting Started](#getting-started)\n    - [Redis commands](#redis-commands)\n- [Command Reference](#command-reference)\n    - [HNSW.NEW](#hnswnew)\n    - [HNSW.GET](#hnswget)\n    - [HNSW.DEL](#hnswdel)\n    - [HNSW.NODE.ADD](#hnswnodeadd)\n    - [HNSW.NODE.GET](#hnswnodeget)\n    - [HNSW.NODE.DEL](#hnswnodedel)\n    - [HNSW.SEARCH](#hnswsearch)\n\n\u003c!-- /TOC --\u003e\n\n## Getting Started\n\u003ca id=\"markdown-getting-started\" name=\"getting-started\"\u003e\u003c/a\u003e\n\n\u003e :warning: **requires nightly rust**\n\nBuild the module - `cargo build`\n\nLoad the module - `redis-server --loadmodule ./target/\u003cbuild_mode\u003e/libredis_hnsw.\u003cdylib|so\u003e`\n\n### Redis commands\n\u003ca id=\"markdown-redis-commands\" name=\"redis-commands\"\u003e\u003c/a\u003e\nCreating a new index - `hnsw.new {index_name} [DIM {data_dim}] [M {m}] [EFCON {ef_construction}]`\n\nAdd nodes - `hnsw.node.add {index_name} {node_name} [DATA {dim} {...data}]`\n\nDelete nodes - `hnsw.node.del {index_name} {node_name}`\n\nSearch KNN - `hnsw.search {index_name} [K {k}] [DATA {dim} {...data}]`\n\n\n## Command Reference\n\u003ca id=\"markdown-command-reference\" name=\"command-reference\"\u003e\u003c/a\u003e\n\n### HNSW.NEW\n\u003ca id=\"markdown-hnsw.new\" name=\"hnsw.new\"\u003e\u003c/a\u003e\n#### Format\n```\nHNSW.NEW {index} [DIM {data_dim}] [M {m}] [EFCON {ef_construction}]\n```\n#### Description\nCreates an HNSW index \n#### Example\n```\nHNSW.NEW foo DIM 128 M 5 EFCON 200\n```\n#### Parameters\n* **index**: required, name of the new index.\n* **DIM**: required, dimensionality of the data.\n* **M**: optional, algorithm parameter for the number of neighbors to select for each node.\n* **EFCON**: optional, algorithm parameter for the size of the dynamic candidate list.\n#### Complexity\nO(1)\n#### Returns\nOK or an error\n\n### HNSW.GET\n\u003ca id=\"markdown-hnsw.get\" name=\"hnsw.get\"\u003e\u003c/a\u003e\n#### Format\n```\nHNSW.GET {index}\n```\n#### Description\nRetrieves an HNSW index \n#### Example\n```\nHNSW.GET foo\n```\n#### Parameters\n* **index**: required, name of the index.\n#### Complexity\nO(1)\n#### Returns\n**Array Reply** key-value pairs of index attributes\n\n### HNSW.DEL\n\u003ca id=\"markdown-hnsw.del\" name=\"hnsw.del\"\u003e\u003c/a\u003e\n#### Format\n```\nHNSW.DEL {index}\n```\n#### Description\nDeletes an HNSW index \n#### Example\n```\nHNSW.DEL foo\n```\n#### Parameters\n* **index**: required, name of the index.\n#### Complexity\nO(1)\n#### Returns\nOK or an error\n\n### HNSW.NODE.ADD\n\u003ca id=\"markdown-hnsw.node.add\" name=\"hnsw.node.add\"\u003e\u003c/a\u003e\n#### Format\n```\nHNSW.NODE.ADD {index} {node} [DATA {dim} {...data}]\n```\n#### Description\nAdds an element to the index \n#### Example\n```\nHNSW.NODE.ADD foo bar DATA 4 1.0 1.0 1.0 1.0\n```\n#### Parameters\n* **index**: required, name of the index\n* **node**: required, name of the new node\n* **DATA**: required, dimensionality followed by a space separated vector of data. Total entries must match `DIM` of index\n#### Complexity\nO(log(n)) where n is the number of nodes in the index\n#### Returns\nOK or an error\n\n### HNSW.NODE.GET\n\u003ca id=\"markdown-hnsw.node.get\" name=\"hnsw.node.get\"\u003e\u003c/a\u003e\n#### Format\n```\nHNSW.NODE.GET {index} {node}\n```\n#### Description\nRetrieves an element from the index \n#### Example\n```\nHNSW.NODE.GET foo bar\n```\n#### Parameters\n* **index**: required, name of the index\n* **node**: required, name of the node\n#### Complexity\nO(1)\n#### Returns\n**Array Reply** key-value pairs of node attributes\n\n### HNSW.NODE.DEL\n\u003ca id=\"markdown-hnsw.node.del\" name=\"hnsw.node.del\"\u003e\u003c/a\u003e\n#### Format\n```\nHNSW.NODE.DEL {index} {node}\n```\n#### Description\nRemoves an element from the index \n#### Example\n```\nHNSW.NODE.DEL foo bar\n```\n#### Parameters\n* **index**: required, name of the index\n* **node**: required, name of the node\n#### Complexity\nO(log(n)) where n is the number of nodes in the index\n#### Returns\nOK or an error\n\n### HNSW.SEARCH\n\u003ca id=\"markdown-hnsw.search\" name=\"hnsw.search\"\u003e\u003c/a\u003e\n#### Format\n```\nHNSW.SEARCH {index} [K {k}] [QUERY {dim} {...data}]\n```\n#### Description\nSearch the index for the K nearest elements to the query\n#### Example\n```\nHNSW.SEARCH foo K 5 QUERY 4 0.0 0.0 0.0 0.0\n```\n#### Parameters\n* **index**: required, name of the index\n* **K**: required, number of nearest neighbors to return\n* **DATA**: required, dimensionality followed by space separated vector of query data. Total entries must match `DIM` of index\n#### Complexity\nO(log(n)) where n is the number of nodes in the index\n#### Returns\n**Array Reply** where the first element is the number of results, followed by key-value pairs of similiarity and returned node key.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzhao-lang%2Fredis_hnsw","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzhao-lang%2Fredis_hnsw","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzhao-lang%2Fredis_hnsw/lists"}