pgvector / pgvector-python

pgvector support for Python
MIT License
979 stars 63 forks source link

Sqlalchemy example not working #65

Closed mkornacker closed 7 months ago

mkornacker commented 7 months ago

I just tried to create an index via Sqlalchemy, following the instructions in the readme: idx = sql.Index( '...', , postgresql_using='hnsw', postgresql_with={'m': 16, 'ef_construction': 64}, postgresql_ops={'embedding': 'vector_cosine_ops'} ) idx.create(bind=...)

which ends up running (notice that the vector_cosine_ops didn't make it into the statement): 'CREATE INDEX idx_617bbefd304a4d1abbef9cfb75012fb9_0 ON tbl_617bbefd304a4d1abbef9cfb75012fb9 USING hnsw (idx_0_col) WITH (m = 16, ef_construction = 64)'

and I'm getting the following error: sqlalchemy.exc.ProgrammingError: (psycopg2.errors.UndefinedObject) data type vector has no default operator class for access method "hnsw"

This is on pgvector 0.2.5

ankane commented 7 months ago

Hi @mkornacker, I'm not sure how to reproduce. The test works fine.

fablerq commented 7 months ago

@mkornacker I faced the same issue, I changed "{'embedding': 'vector_cosine_ops'}" to the actual name of my vector field and it worked