postgresql - jsonb文本搜索索引
问题描述
我将地址数据拆分为 JSONB 列中的字段
我想对这些数据进行自由文本搜索,并注意到 postgres 11 具有函数 jsonb_to_tsvector()
我正在尝试在我的表上创建一个索引: -
CREATE INDEX ad_jsonb_ts_vector
ON my_address_data
USING GIN (jsonb_to_tsvector('English'::regconfig, address_data::JSONB, jsonb_build_array('text', 'numeric')));
这给了我错误:-
ERROR: functions in index expression must be marked IMMUTABLE
SQL state: 42P17
但据我了解,这种形式的 jsonb_to_tsvector 是不可变的吗?
select provolatile from pg_proc
where proname = 'jsonb_to_tsvector'
AND oid::regprocedure ='jsonb_to_tsvector(regconfig,jsonb,jsonb)'::regprocedure
返回“我”。
我错过了什么还是这是一个 postgres 错误。版本是 11.5
解决方案
函数 jsonb_build_array 是稳定的,不是一成不变的。试试这个:
CREATE INDEX ad_jsonb_ts_vector
ON my_address_data
USING GIN (jsonb_to_tsvector('English'::regconfig, address_data::JSONB, '["text", "numeric"]'::jsonb));
推荐阅读
- c++ - c++字符串常量和静态初始化顺序惨败
- c# - 如果 materialId 和 depotId 列相同,我想总结我的 IncomingProduct 表的金额列。最后我想减去这些。MVC C#
- amazon-web-services - 通过使用 Terraform 提供 AWS 区域,在现有 VPC 中预置 EC2
- python - 如何加快解析json和写入数据库的速度?
- php - 没有权限。无法将文件写入 COM4 的打印机
- ssl - JMX 通过 SSL 连接到 Gemfire
- python - I want to read from a file and scrape each URL
- sql - 识别函数何时在 SQL 查询或 PL/SQL 过程中执行
- c# - 如何从 API 中获取值?
- c# - 如何做一个滚动重复的游戏对象