Re: [PATCH] few fts functions for jsonb

From: Oleg Bartunov <obartunov(at)gmail(dot)com>
To: Dmitry Dolgov <9erthalion6(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCH] few fts functions for jsonb
Date: 2017-02-28 12:21:39
Message-ID: CAF4Au4wB3qGsXQs86Yb-n3MiqycvhGRHBqn+SAxH9TGDfCg6Ag@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

The proposed patch looks not very important, but I consider it as an
important feature, which Oracle and Microsoft already have, that's why I
asked Dmitry to work on this and made it before feature freeze. My comments
follows below the post.

On Tue, Feb 28, 2017 at 1:59 PM, Dmitry Dolgov <9erthalion6(at)gmail(dot)com>
wrote:

> 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?
>

1. add json support
2. Its_headline should returns the original json with highlighting. As a
first try the proposed ts_headline could be ok, probably need special
option.

> --
> Sent via pgsql-hackers mailing list (pgsql-hackers(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-hackers
>
>

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2017-02-28 12:39:03 Re: timeouts in PostgresNode::psql
Previous Message Amit Kapila 2017-02-28 11:55:38 Re: Enabling parallelism for queries coming from SQL or other PL functions