Add json(b)_to_tsvector function

Enterprise / PostgreSQL - Teodor Sigaev [sigaev.ru] - 7 April 2018 17:58 EDT

Jsonb has a complex nature so there isn't best-for-everything way to convert it to tsvector for full text search. Current to_tsvector(json(b)) suggests to convert only string values, but it's possible to index keys, numerics and even booleans value. To solve that json(b)_to_tsvector has a second required argument contained a list of desired types of json fields. Second argument is a jsonb scalar or array right now with possibility to add new options in a future.

Bump catalog version

Author: Dmitry Dolgov with some editorization by me Reviewed by: Teodor Sigaev Discussion: https://www.postgresql.org/message-id/CA+q6zcXJQbS1b4kJ_HeAOoOc=unfnOrUEL=KGgE32QKDww7d8g@mail.gmail.com

1c1791e000 Add json(b)_to_tsvector function
doc/src/sgml/func.sgml | 20 ++++
src/backend/tsearch/to_tsany.c | 128 ++++++++++++++++++++++----
src/backend/utils/adt/jsonfuncs.c | 179 ++++++++++++++++++++++++++++++++----
src/include/catalog/catversion.h | 2 +-
src/include/catalog/pg_proc.h | 24 +++--
src/include/utils/jsonapi.h | 21 ++++-
src/test/regress/expected/json.out | 122 ++++++++++++++++++++++++
src/test/regress/expected/jsonb.out | 122 ++++++++++++++++++++++++
src/test/regress/sql/json.sql | 30 ++++++
src/test/regress/sql/jsonb.sql | 30 ++++++
10 files changed, 629 insertions(+), 49 deletions(-)

Upstream: git.postgresql.org


  • Share