日本熟妇hd丰满老熟妇,中文字幕一区二区三区在线不卡 ,亚洲成片在线观看,免费女同在线一区二区

文本搜索函數和操作符

本文介紹了PolarDB PostgreSQL版(兼容Oracle)支持的文本搜搜函數和操作符。

文本搜索操作符表,文本搜索函數表和文本搜索調試函數表總結了為全文搜索提供的函數和操作符。

文本搜索操作符

tsvector @@ tsqueryboolean

tsquery @@ tsvectorboolean

tsvector匹配tsquery嗎?(參數可以按任意順序給出)

to_tsvector('fat cats ate rats') @@ to_tsquery('cat & rat')t

text @@ tsqueryboolean

隱式調用to_tsvector()后的文本字符串匹配tsquery么 ?

'fat cats ate rats' @@ to_tsquery('cat & rat')t

tsvector @@@ tsqueryboolean

tsquery @@@ tsvectorboolean

這是@@已棄用的同義詞。

to_tsvector('fat cats ate rats') @@@ to_tsquery('cat & rat')t

tsvector || tsvectortsvector

連接兩個tsvector。如果兩個輸入都包含詞素位置,則相應地調整第二個輸入的位置。

'a:1 b:2'::tsvector || 'c:1 d:2 b:3'::tsvector'a':1 'b':2,5 'c':3 'd':4

tsquery && tsquerytsquery

ANDs兩個tsquery一起,生成一個匹配兩個輸入查詢的匹配文檔的查詢。

'fat | rat'::tsquery && 'cat'::tsquery( 'fat' | 'rat' ) & 'cat'

tsquery || tsquerytsquery

ORs兩個tsquery一起,生成一個匹配兩個輸入查詢的匹配文檔的查詢。

'fat | rat'::tsquery || 'cat'::tsquery'fat' | 'rat' | 'cat'

!! tsquerytsquery

否定tsquery,生成一個與輸入查詢不匹配的匹配文檔的查詢。

!! 'cat'::tsquery!'cat'

tsquery <-> tsquerytsquery

構造一個短語查詢,如果兩個輸入查詢在連續的詞素上匹配,該查詢將進行匹配。

to_tsquery('fat') <-> to_tsquery('rat')'fat' <-> 'rat'

tsquery @> tsqueryboolean

第一個tsquery包含了第二個嗎?(這只考慮出現在一個查詢中的所有詞素是否出現在另一個查詢中,忽略了組合操作符)

'cat'::tsquery @> 'cat & rat'::tsqueryf

tsquery <@ tsqueryboolean

第一個tsquery包含在第二個中嗎?(這只考慮出現在一個查詢中的所有詞素是否出現在另一個查詢中,而忽略了組合操作符)

'cat'::tsquery <@ 'cat & rat'::tsqueryt

'cat'::tsquery <@ '!cat & rat'::tsqueryt

除了這些專用操作符之外, 比較操作符表中所示的常用比較操作符也適用于tsvectortsquery類型。 它們對于文本搜索不是很有用,但是允許使用。例如,建在這些類型列上的唯一索引。

文本搜索函數

array_to_tsvector ( text[] ) → tsvector

將詞素數組轉換為tsvector。給定的字符串按原樣使用,不做進一步處理。

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賦給列在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對象的字段的“document order”取決于實現;請觀察這些例子中的差異)

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對象字段的“document order”取決于實現) filter必須是一個jsonb數組,其中包含0個或多個關鍵字: "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

ts_delete('fat:2,4 cat:3 rat:5A'::tsvector, 'fat')'cat':3 'rat':5A

ts_delete ( vector tsvector, lexemes text[] ) → tsvector

vector中刪除lexemes中出現的任何詞位。

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

以縮寫形式顯示documentquery的匹配項,該匹配項必須是原始文本,而不是tsvector。 在匹配查詢之前,文檔中的單詞將根據指定的或默認的配置進行規范化。

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

以縮寫形式顯示匹配JSONdocument中字符串值中的query

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

計算一個分數,顯示vectorquery的匹配程度。

ts_rank(to_tsvector('raining cats and dogs'), 'cat')0.06079271

ts_rank_cd ( [ weights real[], ] vector tsvector, query tsquery [, normalization integer ] ) → real

使用覆蓋密度算法計算一個分數,顯示vectorquery的匹配程度。

ts_rank_cd(to_tsvector('raining cats and dogs'), 'cat')0.1

ts_rewrite ( query tsquery, target tsquery, substitute tsquery ) → tsquery

query中使用 substitute替換出現的target

ts_rewrite('a & b'::tsquery, 'a'::tsquery, 'foo|bar'::tsquery)'b' & ( 'foo' | 'bar' )

ts_rewrite ( query tsquery, select text ) → tsquery

根據目標替換部分query,并替換通過執行SELECT命令獲得的查詢。

SELECT ts_rewrite('a & b'::tsquery, 'SELECT t,s FROM aliases')'b' & ( 'foo' | 'bar' )

tsquery_phrase ( query1 tsquery, query2 tsquery ) → tsquery

構造一個短語查詢,在連續的詞位上搜索query1query2的匹配項(與<->操作符相同)。

tsquery_phrase(to_tsquery('fat'), to_tsquery('cat'))'fat' <-> 'cat'

tsquery_phrase ( query1 tsquery, query2 tsquery, distance integer ) → tsquery

構造一個短語查詢,用于搜索query1query2的匹配項,這些匹配項恰好出現在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)

重要

所有接受一個可選的regconfig參數的文本搜索函數在該參數被忽略時,使用由 default_text_search_config 指定的配置。

文本搜索調試函數表中的函數被單獨列出,因為它們通常不被用于日常的文本搜索操作。 它們主要有助于開發和調試新的文本搜索配置。

文本搜索調試函數

ts_debug ( [ config regconfig, ] document text ) → setof record ( alias text, description text, token text, dictionaries regdictionary[], dictionary regdictionary, lexemes text[] )

根據指定的或默認的文本搜索配置從document中提取和標準化標記,并返回關于每個標記是如何處理的信息。

ts_debug('english', 'The Brightest supernovaes')(asciiword,"Word, all ASCII",The,{english_stem},english_stem,{}) ...

ts_lexize ( dict regdictionary, token text ) → text[]

如果字典知道輸入標記,則返回替換詞位數組;如果字典知道標記,但它是停止詞,則返回空數組;如果它不是已知詞,則返回NULL。

ts_lexize('english_stem', 'stars'){star}

ts_parse ( parser_name text, document text ) → setof record ( tokid integer, token text )

使用命名的解析器從document中提取標記。

ts_parse('default', 'foo - bar')(1,foo) ...

ts_parse ( parser_oid oid, document text ) → setof record ( tokid integer, token text )

使用OID指定的解析器從document中提取標記。

ts_parse(3722, 'foo - bar')(1,foo) ...

ts_token_type ( parser_name text ) → setof record ( tokid integer, alias text, description text )

返回一個表,該表描述命名解析器可以識別的每種類型的標記。

ts_token_type('default')(1,asciiword,"Word, all ASCII") ...

ts_token_type ( parser_oid oid ) → setof record ( tokid integer, alias text, description text )

返回一個表,該表描述OID指定的解析器可以識別的每種標記類型。

ts_token_type(3722)(1,asciiword,"Word, all ASCII") ...

ts_stat ( sqlquery text [, weights text ] ) → setof record ( word text, ndoc integer, nentry integer )

執行sqlquery,該查詢必須返回單個tsvector列,并返回關于數據中包含的每個不同詞位的統計信息。

ts_stat('SELECT vector FROM apod')(foo,10,15) ...