From 4585cffce1af694639662cff9436e7225acfdcae Mon Sep 17 00:00:00 2001 From: Aurelius Huang Date: Mon, 30 Sep 2024 16:32:23 +0800 Subject: [PATCH] fix: Compatible with special characters in pg full-text search. (#8921) Co-authored-by: Aurelius Huang --- api/core/rag/datasource/vdb/pgvector/pgvector.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/core/rag/datasource/vdb/pgvector/pgvector.py b/api/core/rag/datasource/vdb/pgvector/pgvector.py index d90707ebc..25a10a1e4 100644 --- a/api/core/rag/datasource/vdb/pgvector/pgvector.py +++ b/api/core/rag/datasource/vdb/pgvector/pgvector.py @@ -166,7 +166,7 @@ class PGVector(BaseVector): with self._get_cursor() as cur: cur.execute( - f"""SELECT meta, text, ts_rank(to_tsvector(coalesce(text, '')), to_tsquery(%s)) AS score + f"""SELECT meta, text, ts_rank(to_tsvector(coalesce(text, '')), plainto_tsquery(%s)) AS score FROM {self.table_name} WHERE to_tsvector(text) @@ plainto_tsquery(%s) ORDER BY score DESC