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
為 vector 的每個元素分配指定的 weight 。
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
為 vector 中列在 lexemes 中的元素分配指定的 weight 。 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
根據 filter 請求的 JSON 文件中的每個項進行選擇,並將每個項轉換為 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 字串將按原樣用作詞位,無需進一步處理。
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 中用 substitute 替換 target 的出現。有關詳細資訊,請參閱 第 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
構建一個短語查詢,搜尋 query1 和 query2 在連續詞位上的匹配(與 <-> 運算子相同)。
tsquery_phrase(to_tsquery('fat'), to_tsquery('cat')) → 'fat' <-> 'cat'
|
tsquery_phrase ( query1 tsquery , query2 tsquery , distance integer ) → tsquery
構建一個短語查詢,搜尋 query1 和 query2 相距正好 distance 個詞位的匹配。
tsquery_phrase(to_tsquery('fat'), to_tsquery('cat'), 10) → 'fat' <10> 'cat'
|
tsvector_to_array ( tsvector ) → text[]
將 tsvector 轉換為詞位陣列。
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 展開為一組行,每行一個詞位。
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}
|