gpt4 book ai didi

postgresql - 我如何让 Postgresql 反射(reflect)对文本搜索配置所做的更改?

转载 作者:行者123 更新时间:2023-11-29 13:57:29 26 4
gpt4 key购买 nike

我正在尝试构建一个将 ISO 日期(如“2015-02-19”)视为单个标记的 Postgresql 文本搜索配置。所有默认配置都包括 int 和 uint 解析器,它们会将日期分解为几个子标记。

development=# SELECT * FROM ts_debug('english', '2371-05-01');
alias | description | token | dictionaries | dictionary | lexemes
-------+------------------+-------+--------------+------------+---------
uint | Unsigned integer | 2371 | {simple} | simple | {2371}
int | Signed integer | -05 | {simple} | simple | {-05}
int | Signed integer | -01 | {simple} | simple | {-01}

使用 Postgres documentation on customizing text search configurationsdocs on the available parser token types you can include in a config ,我做了一个看起来应该可以工作的配置:

development=# \dF+ iso_dates
Text search configuration "public.iso_dates"
Parser: "pg_catalog.default"
Token | Dictionaries
----------+--------------
numhword | simple
numword | simple

但是,当我尝试使用该配置时,它仍然会解析 int 和 uint 标记。

development=# SELECT * FROM ts_debug('public.iso_dates', '2371-05-01');
alias | description | token | dictionaries | dictionary | lexemes
-------+------------------+-------+--------------+------------+---------
uint | Unsigned integer | 2371 | {} | |
int | Signed integer | -05 | {} | |
int | Signed integer | -01 | {} | |

这是怎么回事? Postgres 在接受我的更改之前是否需要其他命令?我已经重新启动了数据库服务器,但不知道还能尝试什么。

最佳答案

在您的情况下,您可以看到您的查询想要使用 unsigned 和 int 配置,但是您的自定义配置 iso_dates 仅为 numwordnumhword 设置。以下内容可能会为您提供所需的内容。

ALTER TEXT SEARCH CONFIGURATION english
ALTER MAPPING FOR numword, numhword, int, uint WITH iso_dates;

关于postgresql - 我如何让 Postgresql 反射(reflect)对文本搜索配置所做的更改?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28616438/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com