Skip to content

Commit 9fd1f72

Browse files
author
Ilia Travnikov
committed
fix sort
1 parent 8c33ad4 commit 9fd1f72

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/services/code-index/vector-store/valkey-search-client.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,6 @@ export class ValkeySearchVectorStore implements IVectorStore {
250250
"2",
251251
"qvec",
252252
vectorBuffer,
253-
"SORTBY",
254-
"score",
255253
"RETURN",
256254
"5",
257255
"score",
@@ -275,7 +273,6 @@ export class ValkeySearchVectorStore implements IVectorStore {
275273
}
276274

277275
const parsedResults: VectorStoreSearchResult[] = []
278-
const totalResults = results[0] as number
279276

280277
for (let i = 1; i < results.length; i += 2) {
281278
const docId = results[i] as string
@@ -296,7 +293,9 @@ export class ValkeySearchVectorStore implements IVectorStore {
296293
})
297294
}
298295

299-
return parsedResults.filter((r) => r.score >= (minScore || DEFAULT_SEARCH_MIN_SCORE))
296+
return parsedResults
297+
.filter((r) => r.score >= (minScore || DEFAULT_SEARCH_MIN_SCORE))
298+
.sort((a, b) => b.score - a.score)
300299
}
301300

302301
async deletePointsByFilePath(filePath: string): Promise<void> {
@@ -331,7 +330,7 @@ export class ValkeySearchVectorStore implements IVectorStore {
331330
if (Array.isArray(result) && result.length > 1) {
332331
for (let i = 1; i < result.length; i++) {
333332
const docId = result[i] as string
334-
pipeline?.call("JSON.DEL", [docId])
333+
pipeline?.call("DEL", [docId])
335334
}
336335
await pipeline?.exec()
337336
}
@@ -360,7 +359,7 @@ export class ValkeySearchVectorStore implements IVectorStore {
360359
const pipeline = this.client?.pipeline()
361360
for (let i = 1; i < result.length; i++) {
362361
const docId = result[i] as string
363-
pipeline?.call("JSON.DEL", [docId])
362+
pipeline?.call("DEL", [docId])
364363
}
365364
await pipeline?.exec()
366365
}

0 commit comments

Comments
 (0)