https://github.com/jiacai2050/vsag-sqlite
An vector search SQLite extension baked by VSAG.
https://github.com/jiacai2050/vsag-sqlite
knn knn-search sqlite sqlite3 vector vector-database vector-search
Last synced: 4 months ago
JSON representation
An vector search SQLite extension baked by VSAG.
- Host: GitHub
- URL: https://github.com/jiacai2050/vsag-sqlite
- Owner: jiacai2050
- License: apache-2.0
- Created: 2024-12-04T15:05:12.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-12-16T08:36:27.000Z (10 months ago)
- Last Synced: 2025-04-30T07:05:17.534Z (5 months ago)
- Topics: knn, knn-search, sqlite, sqlite3, vector, vector-database, vector-search
- Language: Rust
- Homepage:
- Size: 19.5 KB
- Stars: 7
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.org
- License: LICENSE
Awesome Lists containing this project
README
#+TITLE: vsag-sqlite
#+DATE: 2024-12-04T22:55:37+0800
#+LASTMOD: 2024-12-16T16:36:15+0800
#+AUTHOR: Jiacai Liu[[https://github.com/jiacai2050/vsag-sqlite/actions/workflows/CI.yml][https://github.com/jiacai2050/vsag-sqlite/actions/workflows/CI.yml/badge.svg]]
An vector search SQLite extension baked by [[https://github.com/antgroup/vsag][VSAG]], a vector indexing library used for similarity search.
This extension provide a virtual table allowing users to add vectors to VSAG and do KNN style search. The schema of the virtual table is:
#+begin_src sql
CREATE TABLE vsag(id PRIMARY KEY, vec, distance)
#+end_src
* Usage
Execute SQL below in sqlite:
#+begin_src bash :results verbatim :exports results :wrap src sql
cat test.sql
#+end_src#+RESULTS:
#+begin_src sql.load target/debug/libvsag_sqlite
CREATE VIRTUAL TABLE test_table
USING vsag (dimension=3);INSERT INTO test_table (id, vec)
VALUES (1, '[1,2,3]'), (2, '[11,22,33]'), (3, '[111,232,333]');-- KNN style query
SELECT
id,
distance
FROM
test_table
WHERE
vec MATCH '[1,2,4]';
#+end_srcIf everything works well, the =SELECT= will output:
#+begin_src
1|1.0
2|1341.0
3|173241.0
#+end_src
* Install
** Prebuilt binaries
Go to [[https://github.com/jiacai2050/vsag-sqlite/releases][release page]] to download latest prebuilt binary.After download, set =LD_LIBRARY_PATH= env to where you unzip it.
** Build from source
First install dependencies(tested on Ubuntu, other Linux distributions can refer to [[https://github.com/antgroup/vsag/blob/main/DEVELOPMENT.md][DEVELOPMENT.md]]):
#+begin_src bash
sudo apt install -y gfortran libomp-15-dev lcov
#+end_srcThen build this project:
#+begin_src bash
cargo build
#+end_srcAfter build, set =LD_LIBRARY_PATH= to tell sqlite where to find our so files:
#+begin_src bash
so_file=$(find target -name libvsag.so | head -n1)
cp "${so_file}" ./target/debug
export LD_LIBRARY_PATH=./target/debug
#+end_src