Skip to content

jiacai2050/vsag-sqlite

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vsag-sqlite

https://github.com/jiacai2050/vsag-sqlite/actions/workflows/CI.yml/badge.svg

An vector search SQLite extension baked by 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:

CREATE TABLE vsag(id PRIMARY KEY, vec, distance)

Usage

Execute SQL below in sqlite:

.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]';

If everything works well, the SELECT will output:

1|1.0
2|1341.0
3|173241.0

Install

Prebuilt binaries

Go to 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 DEVELOPMENT.md):

sudo apt install -y gfortran libomp-15-dev lcov

Then build this project:

cargo build

After build, set LD_LIBRARY_PATH to tell sqlite where to find our so files:

so_file=$(find target -name libvsag.so | head -n1)
cp "${so_file}" ./target/debug
export LD_LIBRARY_PATH=./target/debug