Skip to content

Commit

Permalink
fix: change <-> to <=> in the SELECT query (#804)
Browse files Browse the repository at this point in the history
Co-authored-by: Alex Yang <[email protected]>
  • Loading branch information
JT-Dev-215 and himself65 authored May 3, 2024
1 parent f1862cc commit e74fe88
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/silly-horses-carry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"llamaindex": patch
---

fix: change <-> to <=> in the SELECT query
4 changes: 2 additions & 2 deletions packages/core/src/storage/vectorStore/PGVectorStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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
Expand Down

0 comments on commit e74fe88

Please sign in to comment.