sql - 使用 setweight() 时 Postgres 全文搜索错误

标签 sql postgresql full-text-search tx-indexed-search

我在 Fedora 27 64 位上运行 PostgreSQL 9.6.8。当我执行这个查询时:

UPDATE tbl SET textsearchable_index_col = 
setweight(to_tsvector('french', coalesce("col1",'')), 'D') || 
setweight(to_tsvector('french', coalesce("col2",'')), 'D');

我收到这个错误:

ERROR:  cache lookup failed for function 3625

********** Error **********

ERROR: cache lookup failed for function 3625
SQL state: XX000

但是当我执行其中之一时:

UPDATE tbl SET textsearchable_index_col = 
setweight(to_tsvector('french', coalesce("col1",'')), 'D');

UPDATE tbl SET textsearchable_index_col = 
setweight(to_tsvector('french', coalesce("col2",'')), 'D');

我得到:

Query returned successfully: 0 rows affected, 11 msec execution time.

我的问题是,为什么它对任一列单独有效,但在一起时却不起作用? 这link表明应该可以在同一个查询中使用两个列(在第 12.3.1 节的末尾)。

编辑:这是系统为 Laurenz 的查询返回的内容。第一个查询返回

 oprname | oprleft  | oprright | oprcode     
---------+----------+----------+----------
 ||      | tsvector | tsvector | 3625

第二个查询返回一个空结果集。

最佳答案

您的数据库已损坏,并且您缺少函数 tsvector_concat,它是 || 运算符背后的函数。

这是它在健康系统上的样子:

SELECT oprname, oprleft::regtype, oprright::regtype, oprcode
FROM pg_operator
WHERE oid = 3633;

 oprname | oprleft  | oprright |     oprcode     
---------+----------+----------+-----------------
 ||      | tsvector | tsvector | tsvector_concat
(1 row)

SELECT proname, proargtypes::regtype[], prosrc
FROM pg_proc
WHERE oid = 3625;

     proname     |        proargtypes        |     prosrc      
-----------------+---------------------------+-----------------
 tsvector_concat | [0:1]={tsvector,tsvector} | tsvector_concat
(1 row)

您的案例中缺少第二部分。

您应该从备份中恢复。

试着弄清楚你是如何陷入这个烂摊子的,这样你就可以在未来避免它。

关于sql - 使用 setweight() 时 Postgres 全文搜索错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49827313/

相关文章:

c# - 全文搜索和 Entity Framework v1 : is it possible?

python - 不使用数据库\索引的模糊运行时搜索

mysql - 将两行合二为一 - Mysql

sql - 对重叠类型进行分类 - Oracle

asp.net - 如何在 SQL Server 存储过程中用逗号分隔(分割)字符串

sql - 当行不存在时, "SELECT FOR UPDATE"是否会阻止其他连接插入?

json - Pentaho Kettle - 从 JSON 表输出到 Postgresql JSONB 字段

postgresql - Postgres 查询需要很长时间才能获得结果

postgresql - 将 GeoLocation Twitter4J 写入 Postgres

.net - 在 ASP.NET MVC 网站上实现搜索