asg017 / sqlite-vec

A vector search SQLite extension that runs anywhere!
Apache License 2.0
4.24k stars 134 forks source link

PARTITION KEY support #122

Closed asg017 closed 2 days ago

asg017 commented 1 month ago

References #29

Work in progress, needs more bug fixing, docs, and tests.

create virtual table vec_chunks using vec0(
  chunk_id integer primary key,
  user_id integer partition key, --> Partition key!
  contents_embedding float[1],
);

select chunk_id, user_id, distance
from vec_chunks
where contents_embedding match '[19]'
  and user_id = 123
  and k = 5;

/*
┌──────────┬─────────┬──────────┐
│ chunk_id │ user_id │ distance │
├──────────┼─────────┼──────────┤
│ 20       │ 123     │ 1.0      │
│          │         │          │
├──────────┼─────────┼──────────┤
│ 17       │ 123     │ 2.0      │
│          │         │          │
├──────────┼─────────┼──────────┤
│ 15       │ 123     │ 4.0      │
│          │         │          │
├──────────┼─────────┼──────────┤
│ 5        │ 123     │ 14.0     │
├──────────┼─────────┼──────────┤
│ 4        │ 123     │ 15.0     │
│          │         │          │
└──────────┴─────────┴──────────┘
*/
asg017 commented 2 days ago

yolo