From: | Dmitry Dolgov <9erthalion6(at)gmail(dot)com> |
---|---|
To: | PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | [PATCH] few fts functions for jsonb |
Date: | 2017-02-28 10:59:52 |
Message-ID: | CA+q6zcWm_1Ygg5QOq0gYbnB_=zq7G51uexQt3QEgDJa0qQnPKw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
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 <bbb> ccc <ddd>
(1 row)
```
Any comments or suggestions?
Attachment | Content-Type | Size |
---|---|---|
jsonb_fts_v1.patch | text/x-patch | 12.9 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Magnus Hagander | 2017-02-28 11:07:06 | Re: rename pg_log directory? |
Previous Message | Seki, Eiji | 2017-02-28 09:54:17 | [Doc fix] Wrong explanation about tsquery_phrase |