array_to_tsvector ( text[] ) → tsvector
將文字字串陣列轉換為 tsvector 。給定的字串按原樣用作語素,無需進一步處理。陣列元素不能是空字串或 NULL 。
array_to_tsvector('{fat,cat,rat}'::text[]) → 'cat' 'fat' 'rat'
|
get_current_ts_config ( ) → regconfig
傳回目前預設文字搜尋組態的 OID (由 default_text_search_config 設定)。
get_current_ts_config() → english
|
length ( tsvector ) → integer
傳回 tsvector 中的詞位數量。
length('fat:2,4 cat:3 rat:5A'::tsvector) → 3
|
numnode ( tsquery ) → integer
傳回 tsquery 中的詞位和運算子的數量。
numnode('(fat & rat) | cat'::tsquery) → 5
|
plainto_tsquery ( [ config regconfig , ] query text ) → tsquery
將文字轉換為 tsquery ,根據指定的或預設的組態來正規化單字。字串中的任何標點符號都會被忽略(它不會決定查詢運算子)。產生的查詢會符合包含文字中所有非停用詞的文件。
plainto_tsquery('english', 'The Fat Rats') → 'fat' & 'rat'
|
phraseto_tsquery ( [ config regconfig , ] query text ) → tsquery
將文字轉換為 tsquery ,根據指定的或預設的組態來正規化單字。字串中的任何標點符號都會被忽略(它不會決定查詢運算子)。產生的查詢會符合包含文字中所有非停用詞的片語。
phraseto_tsquery('english', 'The Fat Rats') → 'fat' <-> 'rat'
phraseto_tsquery('english', 'The Cat and Rats') → 'cat' <2> 'rat'
|
websearch_to_tsquery ( [ config regconfig , ] query text ) → tsquery
將文字轉換為 tsquery ,根據指定的或預設的組態來正規化單字。引號括住的單字序列會轉換為片語測試。單字 “or” 被理解為產生 OR 運算子,而破折號會產生 NOT 運算子;其他標點符號會被忽略。這近似於一些常見的網路搜尋工具的行為。
websearch_to_tsquery('english', '"fat rat" or cat dog') → 'fat' <-> 'rat' | 'cat' & 'dog'
|
querytree ( tsquery ) → text
產生 tsquery 中可索引部分的表示法。 空或僅包含 T 的結果表示不可索引的查詢。
querytree('foo & ! bar'::tsquery) → 'foo'
|
setweight ( vector tsvector , weight "char" ) → tsvector
將指定的 weight 指派給 vector 的每個元素。
setweight('fat:2,4 cat:3 rat:5B'::tsvector, 'A') → 'cat':3A 'fat':2A,4A 'rat':5A
|
setweight ( vector tsvector , weight "char" , lexemes text[] ) → tsvector
將指定的 weight 指派給 vector 中列在 lexemes 中的元素。 lexemes 中的字串會被視為詞位,而不進行進一步的處理。 不符合 vector 中任何詞位的字串會被忽略。
setweight('fat:2,4 cat:3 rat:5,6B'::tsvector, 'A', '{cat,rat}') → 'cat':3A 'fat':2,4 'rat':5A,6A
|
strip ( tsvector ) → tsvector
從 tsvector 中移除位置和權重。
strip('fat:2,4 cat:3 rat:5A'::tsvector) → 'cat' 'fat' 'rat'
|
to_tsquery ( [ config regconfig , ] query text ) → tsquery
將文字轉換為 tsquery ,根據指定的或預設的組態來正規化單字。這些單字必須透過有效的 tsquery 運算子來組合。
to_tsquery('english', 'The & Fat & Rats') → 'fat' & 'rat'
|
to_tsvector ( [ config regconfig , ] document text ) → tsvector
將文字轉換為 tsvector ,根據指定的或預設的組態來正規化單字。位置資訊會包含在結果中。
to_tsvector('english', 'The Fat Rats') → 'fat':2 'rat':3
|
to_tsvector ( [ config regconfig , ] document json ) → tsvector
to_tsvector ( [ config regconfig , ] document jsonb ) → tsvector
將 JSON 文件中的每個字串值轉換為 tsvector ,根據指定的或預設的組態來正規化單字。然後將結果按照文件順序串連起來以產生輸出。位置資訊的產生方式就像每一對字串值之間存在一個停用詞一樣。(請注意,當輸入為 jsonb 時,JSON 物件欄位的 “文件順序” 取決於實作;請觀察範例中的差異。)
to_tsvector('english', '{"aa": "The Fat Rats", "b": "dog"}'::json) → 'dog':5 'fat':2 'rat':3
to_tsvector('english', '{"aa": "The Fat Rats", "b": "dog"}'::jsonb) → 'dog':1 'fat':4 'rat':5
|
json_to_tsvector ( [ config regconfig , ] document json , filter jsonb ) → tsvector
jsonb_to_tsvector ( [ config regconfig , ] document jsonb , filter jsonb ) → tsvector
選取 JSON 文件中由 filter 請求的每個項目,並根據指定或預設的組態將每個項目轉換為 tsvector ,對單字進行正規化。然後,將結果依文件順序串連起來以產生輸出。位置資訊的產生方式,就像每對選定項目之間存在一個停用詞一樣。(請注意,當輸入為 jsonb 時,JSON 物件欄位的“文件順序”取決於實作方式。)filter 必須是一個 jsonb 陣列,其中包含零個或多個下列關鍵字:"string" (包含所有字串值)、"numeric" (包含所有數值)、"boolean" (包含所有布林值)、"key" (包含所有鍵),或 "all" (包含以上所有)。在特殊情況下,filter 也可以是一個簡單的 JSON 值,並且是這些關鍵字之一。
json_to_tsvector('english', '{"a": "The Fat Rats", "b": 123}'::json, '["string", "numeric"]') → '123':5 'fat':2 'rat':3
json_to_tsvector('english', '{"cat": "The Fat Rats", "dog": 123}'::json, '"all"') → '123':9 'cat':1 'dog':7 'fat':4 'rat':5
|
ts_delete ( vector tsvector , lexeme text ) → tsvector
從 vector 中移除任何給定 lexeme 的出現。 lexeme 字串被視為詞素(lexeme),不進行進一步處理。
ts_delete('fat:2,4 cat:3 rat:5A'::tsvector, 'fat') → 'cat':3 'rat':5A
|
ts_delete ( vector tsvector , lexemes text[] ) → tsvector
從 vector 中移除 lexemes 中任何詞素的出現。lexemes 中的字串被視為詞素,不進行進一步處理。與 vector 中任何詞素不符的字串將被忽略。
ts_delete('fat:2,4 cat:3 rat:5A'::tsvector, ARRAY['fat','rat']) → 'cat':3
|
ts_filter ( vector tsvector , weights "char"[] ) → tsvector
僅從 vector 中選取具有給定 weights 的元素。
ts_filter('fat:2,4 cat:3b,7c rat:5A'::tsvector, '{a,b}') → 'cat':3B 'rat':5A
|
ts_headline ( [ config regconfig , ] document text , query tsquery [, options text ] ) → text
以縮寫形式顯示 query 在 document 中的匹配項,document 必須是原始文字,而不是 tsvector 。在與查詢匹配之前,文件中的單字會根據指定或預設的組態進行正規化。此函數的用法在第 12.3.4 節中討論,該節也描述了可用的 options 。
ts_headline('The fat cat ate the rat.', 'cat') → The fat <b>cat</b> ate the rat.
|
ts_headline ( [ config regconfig , ] document json , query tsquery [, options text ] ) → text
ts_headline ( [ config regconfig , ] document jsonb , query tsquery [, options text ] ) → text
以縮寫形式顯示 JSON document 中字串值內發生的 query 的匹配項。有關更多詳細資料,請參閱第 12.3.4 節。
ts_headline('{"cat":"raining cats and dogs"}'::jsonb, 'cat') → {"cat": "raining <b>cats</b> and dogs"}
|
ts_rank ( [ weights real[] , ] vector tsvector , query tsquery [, normalization integer ] ) → real
計算一個分數,顯示 vector 與 query 的匹配程度。 有關詳細資料,請參閱第 12.3.3 節。
ts_rank(to_tsvector('raining cats and dogs'), 'cat') → 0.06079271
|
ts_rank_cd ( [ weights real[] , ] vector tsvector , query tsquery [, normalization integer ] ) → real
計算一個分數,顯示 vector 與 query 的匹配程度,使用覆蓋密度演算法。 有關詳細資料,請參閱第 12.3.3 節。
ts_rank_cd(to_tsvector('raining cats and dogs'), 'cat') → 0.1
|
ts_rewrite ( query tsquery , target tsquery , substitute tsquery ) → tsquery
將 query 中 target 的出現替換為 substitute 。 有關詳細資料,請參閱第 12.4.2.1 節。
ts_rewrite('a & b'::tsquery, 'a'::tsquery, 'foo|bar'::tsquery) → 'b' & ( 'foo' | 'bar' )
|
ts_rewrite ( query tsquery , select text ) → tsquery
根據執行 SELECT 指令所獲得的目標 (target) 與替換 (substitute) 內容,替換 query 的部分內容。詳情請參閱第 12.4.2.1 節。
SELECT ts_rewrite('a & b'::tsquery, 'SELECT t,s FROM aliases') → 'b' & ( 'foo' | 'bar' )
|
tsquery_phrase ( query1 tsquery , query2 tsquery ) → tsquery
建構一個片語查詢,尋找連續詞位 (lexeme) 中 query1 和 query2 的匹配項(與 <-> 運算子相同)。
tsquery_phrase(to_tsquery('fat'), to_tsquery('cat')) → 'fat' <-> 'cat'
|
tsquery_phrase ( query1 tsquery , query2 tsquery , distance integer ) → tsquery
建構一個片語查詢,尋找間隔恰好 distance 個詞位的 query1 和 query2 的匹配項。
tsquery_phrase(to_tsquery('fat'), to_tsquery('cat'), 10) → 'fat' <10> 'cat'
|
tsvector_to_array ( tsvector ) → text[]
將 tsvector 轉換為詞位 (lexeme) 的陣列。
tsvector_to_array('fat:2,4 cat:3 rat:5A'::tsvector) → {cat,fat,rat}
|
unnest ( tsvector ) → setof record ( lexeme text , positions smallint[] , weights text )
將 tsvector 展開為一組列,每列一個詞位 (lexeme)。
select * from unnest('cat:3 fat:2,4 rat:5A'::tsvector) →
lexeme | positions | weights
--------+-----------+---------
cat | {3} | {D}
fat | {2,4} | {D,D}
rat | {5} | {A}
|