summaryrefslogtreecommitdiff
path: root/doc/src
diff options
context:
space:
mode:
authorTeodor Sigaev <teodor@sigaev.ru>2018-04-07 20:58:03 +0300
committerTeodor Sigaev <teodor@sigaev.ru>2018-04-07 20:58:03 +0300
commit1c1791e00065f6986f9d44a78ce7c28b2d1322dd (patch)
tree7287b278140f8fe30ceb289146afc4fdcc97a040 /doc/src
parent529ab7bd1fb9c836fe5ccd96f79329d407522e20 (diff)
Add json(b)_to_tsvector function
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
Diffstat (limited to 'doc/src')
-rw-r--r--doc/src/sgml/func.sgml20
1 files changed, 20 insertions, 0 deletions
diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml
index a86d3f40f17..3dbfa1dec34 100644
--- a/doc/src/sgml/func.sgml
+++ b/doc/src/sgml/func.sgml
@@ -9729,6 +9729,26 @@ CREATE TYPE rainbow AS ENUM ('red', 'orange', 'yellow', 'green', 'blue', 'purple
</row>
<row>
<entry>
+ <literal><function>json(b)_to_tsvector(<optional> <replaceable class="parameter">config</replaceable> <type>regconfig</type>,
+ </optional> <replaceable class="parameter">document</replaceable> <type>json(b)</type>,
+ <replaceable class="parameter">filter</replaceable> <type>json(b)</type>)</function></literal>
+ </entry>
+ <entry><type>tsvector</type></entry>
+ <entry>
+ reduce each value in the document, specified by <replaceable class="parameter">filter</replaceable> to a <type>tsvector</type>,
+ and then concatenate those in document order to produce a single <type>tsvector</type>.
+ <replaceable class="parameter">filter</replaceable> is a jsonb array, that enumerates what kind of elements need to be included
+ into the resulting <type>tsvector</type>. Possible values for <replaceable class="parameter">filter</replaceable> are
+ <literal>"string"</literal> (to include all string values), <literal>"numeric"</literal> (to include all numeric values in the string format),
+ <literal>"boolean"</literal> (to include all boolean values in the string format "true"/"false"),
+ <literal>"key"</literal> (to include all keys) or <literal>"all"</literal> (to include all above). These values
+ can be combined together to include, e.g. all string and numeric values.
+ </entry>
+ <entry><literal>json_to_tsvector('english', '{"a": "The Fat Rats", "b": 123}'::json, '["string", "numeric"]')</literal></entry>
+ <entry><literal>'123':5 'fat':2 'rat':3</literal></entry>
+ </row>
+ <row>
+ <entry>
<indexterm>
<primary>ts_delete</primary>
</indexterm>