refactor: Rewrite search query
Optimize search query for PGVector Refactor #COG-170
This commit is contained in:
parent
58e5854943
commit
325e6cd654
1 changed files with 1 additions and 1 deletions
|
|
@ -164,7 +164,7 @@ class PGVectorAdapter(SQLAlchemyAdapter, VectorDBInterface):
|
||||||
try:
|
try:
|
||||||
PGVectorDataPoint = Table(collection_name, Base.metadata, autoload_with=self.engine)
|
PGVectorDataPoint = Table(collection_name, Base.metadata, autoload_with=self.engine)
|
||||||
|
|
||||||
closest_items = await session.execute(select(PGVectorDataPoint, PGVectorDataPoint.c.vector.cosine_distance(query_vector).label('similarity')).order_by(PGVectorDataPoint.c.vector.cosine_distance(query_vector)).limit(limit))
|
closest_items = await session.execute(select(PGVectorDataPoint, PGVectorDataPoint.c.vector.cosine_distance(query_vector).label('similarity')).order_by('similarity').limit(limit))
|
||||||
|
|
||||||
vector_list = []
|
vector_list = []
|
||||||
# Extract distances and find min/max for normalization
|
# Extract distances and find min/max for normalization
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue