我的表有以下列:
- content_vector tsvector
- 語言 VARCHAR(50)
我正在努力創建 GIN 索引。
方法一:顯式型別轉換
CREATE INDEX pages_vector_ix ON pages USING GIN (to_tsvector(lang::regconfig, content_vector));
盡管使用了本文中描述的顯式型別轉換,但這會產生以下錯誤:
function to_tsvector(regconfig, tsvector) does not exist
方法二:改變列的型別
還應該可以根據這篇文章將列型別更改為重新配置 :
ALTER TABLE pages ALTER COLUMN lang TYPE reconfig USING lang::reconfig;
現在我收到一個錯誤,因為顯然我在資料庫中存盤了不能用作文本??搜索配置的語言,例如:
text search configuration "afrikaans" does not exist
這個錯誤讓我懷疑如果資料庫中存盤了 Postgres 不支持的潛在語言,是否可以設定 GIN 索引。
附加資訊
select * from pg_catalog.pg_ts_config;
結果是
cfgname | cfgnamespace | cfgowner | cfgparser
------------ -------------- ---------- -----------
simple | 11 | 10 | 3722
danish | 11 | 10 | 3722
dutch | 11 | 10 | 3722
english | 11 | 10 | 3722
finnish | 11 | 10 | 3722
french | 11 | 10 | 3722
german | 11 | 10 | 3722
hungarian | 11 | 10 | 3722
italian | 11 | 10 | 3722
norwegian | 11 | 10 | 3722
portuguese | 11 | 10 | 3722
romanian | 11 | 10 | 3722
russian | 11 | 10 | 3722
spanish | 11 | 10 | 3722
swedish | 11 | 10 | 3722
turkish | 11 | 10 | 3722
uj5u.com熱心網友回復:
由于 content_vector 已經是 tsvector,只需在其上構建索引即可。to_tsvector 不將 tsvector 作為第二個引數,這沒有意義。
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/498447.html
標籤:PostgreSQL 索引 全文搜索
下一篇:替換JSON檔案中字典串列中的值