【问题标题】:How do I get Postgresql to reflect changes made to a text search configuration?如何让 Postgresql 反映对文本搜索配置所做的更改?
【发布时间】:2016-10-13 19:52:55
【问题描述】:

我正在尝试构建一个 Postgresql 文本搜索配置,它将 ISO 日期(如“2015-02-19”)视为单个标记。所有默认配置都包括 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 在接受我的更改之前是否需要其他命令?我已经重新启动了数据库服务器,但不知道还能尝试什么。

【问题讨论】:

    标签: postgresql full-text-search


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-09-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-11
      • 2015-05-09
      相关资源
      最近更新 更多