From 6943a946c7e5eb72d53c0ce71f08a81a133503bd Mon Sep 17 00:00:00 2001
From: Teodor Sigaev
Date: Fri, 11 Mar 2016 19:22:36 +0300
Subject: Tsvector editing functions
Adds several tsvector editting function: convert tsvector to/from text array,
set weight for given lexemes, delete lexeme(s), unnest, filter lexemes
with given weights
Author: Stas Kelvich with some editorization by me
Reviewers: Tomas Vondram, Teodor Sigaev
---
doc/src/sgml/func.sgml | 91 +++++++++++++++++++++++++++++++++++++++++++-
doc/src/sgml/textsearch.sgml | 4 ++
2 files changed, 93 insertions(+), 2 deletions(-)
(limited to 'doc/src')
diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml
index 4b5ee8135f..000489d961 100644
--- a/doc/src/sgml/func.sgml
+++ b/doc/src/sgml/func.sgml
@@ -9211,13 +9211,26 @@ CREATE TYPE rainbow AS ENUM ('red', 'orange', 'yellow', 'green', 'blue', 'purple
setweight
- setweight(tsvector>, "char">)
+ setweight(vector tsvector>, weight "char">)
tsvector
- assign weight to each element of tsvector>
+ assign weight to each element of vector
setweight('fat:2,4 cat:3 rat:5B'::tsvector, 'A')
'cat':3A 'fat':2A,4A 'rat':5A
+
+
+
+ setweight
+ setweight by filter
+
+ setweight(vector tsvector>, weight "char">, lexemes "text"[]>)
+
+ tsvector
+ assign weight to elements of vector that are listed in lexemes array
+ setweight('fat:2,4 cat:3 rat:5B'::tsvector, 'A', '{cat,rat}')
+ 'cat':3A 'fat':2,4 'rat':5A
+
@@ -9230,6 +9243,80 @@ CREATE TYPE rainbow AS ENUM ('red', 'orange', 'yellow', 'green', 'blue', 'purple
strip('fat:2,4 cat:3 rat:5A'::tsvector)
'cat' 'fat' 'rat'
+
+
+
+ delete
+ delete lemexeme
+
+ delete(vector tsvector>, lexeme text>)
+
+ tsvector
+ remove given lexeme from vector
+ delete('fat:2,4 cat:3 rat:5A'::tsvector, 'fat')
+ 'cat':3 'rat':5A
+
+
+
+
+ delete
+ delete lemexemes array
+
+ delete(vector tsvector>, lexemes text[]>)
+
+ tsvector
+ remove any occurrence of lexemes in lexemes array from vector
+ delete('fat:2,4 cat:3 rat:5A'::tsvector, ARRAY['fat','rat'])
+ 'cat':3
+
+
+
+
+ unnest
+
+ unnest(tsvector>, OUT lexeme> text>, OUT positions> smallint[]>, OUT weights> text>)
+
+ setof record
+ expand a tsvector to a set of rows
+ unnest('fat:2,4 cat:3 rat:5A'::tsvector)
+ (cat,{3},{D}) ...
+
+
+
+
+ tsvector_to_array
+
+ tsvector_to_array(tsvector>)
+
+ text[]
+ convert tsvector> to array of lexemes
+ tsvector_to_array('fat:2,4 cat:3 rat:5A'::tsvector)
+ {cat,fat,rat}
+
+
+
+
+ array_to_tsvector
+
+ array_to_tsvector(text[]>)
+
+ tsvector
+ convert array of lexemes to tsvector
+ array_to_tsvector('{fat,cat,rat}'::text[])
+ 'fat' 'cat' 'rat'
+
+
+
+
+ filter
+
+ filter(vector tsvector>, weights "char"[]>)
+
+ tsvector
+ Select only elements with given weights from vector
+ filter('fat:2,4 cat:3b rat:5A'::tsvector, '{a,b}')
+ 'cat':3B 'rat':5A
+
diff --git a/doc/src/sgml/textsearch.sgml b/doc/src/sgml/textsearch.sgml
index ff99976068..ea3abc9e15 100644
--- a/doc/src/sgml/textsearch.sgml
+++ b/doc/src/sgml/textsearch.sgml
@@ -1326,6 +1326,10 @@ FROM (SELECT id, body, q, ts_rank_cd(ti, q) AS rank
+
+ Full list of tsvector>-related functions available in .
+
+
--
cgit v1.2.3