Skip to content

Commit a7ce7bb

Browse files
committed
Added index docs for Peewee [skip ci]
1 parent ff9012e commit a7ce7bb

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,14 @@ Get items within a certain distance
308308
Item.select().where(Item.embedding.l2_distance([3, 1, 2]) < 5)
309309
```
310310

311+
Add an approximate index
312+
313+
```python
314+
Item.add_index('embedding vector_l2_ops', using='hnsw')
315+
```
316+
317+
Use `vector_ip_ops` for inner product and `vector_cosine_ops` for cosine distance
318+
311319
## History
312320

313321
View the [changelog](https://github.com/pgvector/pgvector-python/blob/master/CHANGELOG.md)

tests/test_peewee.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ class Item(BaseModel):
1515
embedding = VectorField(dimensions=3)
1616

1717

18+
Item.add_index('embedding vector_l2_ops', using='hnsw')
19+
1820
db.connect()
1921
db.execute_sql('CREATE EXTENSION IF NOT EXISTS vector')
2022
db.drop_tables([Item])

0 commit comments

Comments
 (0)