diff --git a/.changeset/silly-horses-carry.md b/.changeset/silly-horses-carry.md new file mode 100644 index 0000000000000000000000000000000000000000..2d1b13dcdb0d133c44aa01cb863b7662e29991d4 --- /dev/null +++ b/.changeset/silly-horses-carry.md @@ -0,0 +1,5 @@ +--- +"llamaindex": patch +--- + +fix: change <-> to <=> in the SELECT query diff --git a/packages/core/src/storage/vectorStore/PGVectorStore.ts b/packages/core/src/storage/vectorStore/PGVectorStore.ts index bc59542450a09b7f72f5aae43dbd85955dbbabd5..b48848577c634ca013c028af64a1d1c345b28e7f 100644 --- a/packages/core/src/storage/vectorStore/PGVectorStore.ts +++ b/packages/core/src/storage/vectorStore/PGVectorStore.ts @@ -250,7 +250,7 @@ export class PGVectorStore implements VectorStore { options?: any, ): Promise<VectorStoreQueryResult> { // TODO QUERY TYPES: - // Distance: SELECT embedding <-> $1 AS distance FROM items; + // Distance: SELECT embedding <=> $1 AS distance FROM items; // Inner Product: SELECT (embedding <#> $1) * -1 AS inner_product FROM items; // Cosine Sim: SELECT 1 - (embedding <=> $1) AS cosine_similarity FROM items; @@ -273,7 +273,7 @@ export class PGVectorStore implements VectorStore { const sql = `SELECT v.*, - embeddings <-> $1 s + embeddings <=> $1 s FROM ${this.schemaName}.${this.tableName} v ${where} ORDER BY s