From 3c97cdbff9416a069b3b544937f07fb650e5d9b6 Mon Sep 17 00:00:00 2001 From: mahesh-maan Date: Fri, 17 Jan 2025 14:38:35 +0530 Subject: [PATCH] Fix a bug in concurrent searching --- services/vector_search.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/services/vector_search.py b/services/vector_search.py index 3fc9670..13860ca 100644 --- a/services/vector_search.py +++ b/services/vector_search.py @@ -27,7 +27,8 @@ cache = {} def load_indexes(): - for index_id in indexdir.available(): + index_ids = sorted(indexdir.available()) + for index_id in index_ids: index = indexdir.get(index_id)[0] cache[index_id] = index @@ -47,7 +48,7 @@ async def health(): def search_index(t): idx, qvec, n = t results = cache[idx].search(qvec, n) - results = [(doc_id, idx, score) for doc_id, score in results] + results = [(doc_id, idx, 1.0-dist) for doc_id, dist in results] return results def concurrent_search(idxs, qvec, n):