暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

PostgreSQL 10.0 preview 功能增强 - JSON 内容全文检索

digoal 2017-03-12
207
TAG 13

作者

digoal

日期

2017-03-12

标签

PostgreSQL , 10.0 , jsonb , json , 全文检索


背景

PostgreSQL 10.0 支持JSON内容的全文检索了。

同样支持ts rank和phrase 索引哦。

ts rank, phrase请参考

《从难缠的模糊查询聊开 - PostgreSQL独门绝招之一 GIN , GiST , SP-GiST , RUM 索引原理与技术背景》

```
Hi all

I would like to propose patch with a set of new small functions for fts in
case of
jsonb data type:

  • to_tsvector(config, jsonb) - make a tsvector from all string values and
    elements of jsonb object. To prevent the situation, when tsquery can find
    a
    phrase consisting of lexemes from two different values/elements, this
    function will add an increment to position of each lexeme from every new
    value/element.

  • ts_headline(config, jsonb, tsquery, options) - generate a headline
    directly
    from jsonb object

Here are the examples how they work:

=# select to_tsvector('{"a": "aaa bbb", "b": ["ccc ddd"], "c": {"d": "eee
fff"}}'::jsonb);
to_tsvector


'aaa':1 'bbb':2 'ccc':4 'ddd':5 'eee':7 'fff':8
(1 row)

=# select ts_headline('english', '{"a": "aaa bbb", "b": {"c": "ccc
ddd"}}'::jsonb, tsquery('bbb & ddd & hhh'), 'StartSel = <, StopSel = >');
ts_headline


aaa ccc
(1 row)

Any comments or suggestions?
```

这个patch的讨论,详见邮件组,本文末尾URL。

PostgreSQL社区的作风非常严谨,一个patch可能在邮件组中讨论几个月甚至几年,根据大家的意见反复的修正,patch合并到master已经非常成熟,所以PostgreSQL的稳定性也是远近闻名的。

参考

https://commitfest.postgresql.org/13/1054/

https://www.postgresql.org/message-id/flat/CA+q6zcWm_1Ygg5QOq0gYbnB_=zq7G51uexQt3QEgDJa0qQnPKw@mail.gmail.com#CA+q6zcWm_1Ygg5QOq0gYbnB_=zq7G51uexQt3QEgDJa0qQnPKw@mail.gmail.com

PostgreSQL 许愿链接

您的愿望将传达给PG kernel hacker、数据库厂商等, 帮助提高数据库产品质量和功能, 说不定下一个PG版本就有您提出的功能点. 针对非常好的提议,奖励限量版PG文化衫、纪念品、贴纸、PG热门书籍等,奖品丰富,快来许愿。开不开森.

9.9元购买3个月阿里云RDS PostgreSQL实例

PostgreSQL 解决方案集合

德哥 / digoal's github - 公益是一辈子的事.

digoal's wechat

文章转载自digoal,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论