8c sql手册 五
创始人
2024-04-01 22:23:02
0

可以用于macaddr类型的函数:

函数

返回类型

描述

例子

结果

trunc(macaddr)

macaddr

设置最后3个字节为零

trunc(macaddr '12:34:56:78:90:ab')

12:34:56:00:00:00

可用于macaddr8 类型的函数:

函数

返回类型

描述

示例

结果

trunc(macaddr8)

macaddr8

将最后5个字节设置为零

trunc(macaddr8 '12:34:56:78:90:ab:cd:ef')

12:34:56:00:00:00:00:00

macaddr8_set7bit(macaddr8)

macaddr8

将第7位设置为1,也称为修改的EUI-64,以包含在IPv6地址中

macaddr8_set7bit(macaddr8 '00:34:56:ab:cd:ef')

02:34:56:ff:fe:ab:cd:ef

      1. 文本搜索函数和操作符

文本搜索操作符:

操作符

返回类型

描述

例子

结果

@@

boolean

tsvector匹配tsquery吗?

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

t

@@@

boolean

@@的已废弃同义词

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

t

||

tsvector

连接tsvector

'a:1 b:2'::tsvector || 'c:1 d:2 b:3'::tsvector

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

&&

tsquery

将tsquery用 AND 连接起来

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

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

||

tsquery

将tsquery用 OR 连接起来

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

( 'fat' | 'rat' ) | 'cat'

!!

tsquery

对一个tsquery取反

!! 'cat'::tsquery

!'cat'

<->

tsquery

tsquery后面跟着tsquery

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

'fat' <-> 'rat'

@>

boolean

tsquery包含另一个?

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

f

<@

boolean

tsquery被包含?

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

t

文本搜索函数:

函数

返回类型

描述

例子

结果

array_to_tsvector(text[])

tsvector

把词位数组转换成tsvector

array_to_tsvector('{fat,cat,rat}'::text[])

'cat' 'fat' 'rat'

get_current_ts_config()

regconfig

获得默认文本搜索配置

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'

querytree(query tsquery)

text

获得一个tsquery的可索引部分

querytree('foo & ! bar'::tsquery)

'foo'

setweight(tsvector, "char")

tsvector

为tsvector的每一个元素分配权重

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

lexemes中列出的 vector元素分配 权重

setweight('fat:2,4 cat:3 rat:5B'::tsvector, 'A', '{cat,rat}')

'cat':3A 'fat':2,4 'rat':5A

strip(tsvector)

tsvector

从tsvector中移除位置和权重

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

'cat' 'fat' 'rat'

to_tsquery([ config regconfig , ] query text)

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(b))

tsvector

将文档中的每个字符串值减少到tsvector, 然后按文档顺序连接以生成一个tsvector

to_tsvector('english', '{"a": "The Fat Rats"}'::json)

'fat':2 'rat':3

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 中只选择带有给定权重的元素

ts_filter('fat:2,4 cat:3b rat:5A'::tsvector, '{a,b}')

'cat':3B 'rat':5A

ts_headline([ config regconfig, ] document text, query tsquery [, options text ])

text

显示一个查询匹配

ts_headline('x y z', 'z'::tsquery)

x y z

ts_headline([ config regconfig, ] document json(b), query tsquery [, options text ])

text

显示查询匹配

ts_headline('{"a":"x y z"}'::json, 'z'::tsquery)

{"a":"x y z"}

ts_rank([ weights float4[], ] vector tsvector, query tsquery [, normalization integer ])

float4

为查询排名文档

ts_rank(textsearch, query)

0.818

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

float4

使用覆盖密度为查询排名文档

ts_rank_cd('{0.1, 0.2, 0.4, 1.0}', textsearch, query)

2.01317

ts_rewrite(query tsquery, target tsquery, substitute tsquery)

tsquery

在查询内用 substitute 替换 target

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

'b' & ( 'foo' | 'bar' )

ts_rewrite(query tsquery, select text)

tsquery

使用来自一个SELECT的目标和替换者进行替换

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

'b' & ( 'foo' | 'bar' )

tsquery_phrase(query1 tsquery, query2 tsquery)

tsquery

制造搜索后面跟着query2query1 的查询(和<->操作符相同)

tsquery_phrase(to_tsquery('fat'), to_tsquery('cat'))

'fat' <-> 'cat'

tsquery_phrase(query1 tsquery, query2 tsquery, distance integer)

tsquery

制造查询来搜索在query1后面距离 distance上跟着query2的情况

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}

tsvector_update_trigger()

trigger

用于自动tsvector列更新的触发器函数

CREATE TRIGGER ... tsvector_update_trigger(tsvcol, 'pg_catalog.swedish', title, body)

tsvector_update_trigger_column()

trigger

用于自动tsvector列更新的触发器函数

CREATE TRIGGER ... tsvector_update_trigger_column(tsvcol, configcol, title, body)

unnest(tsvector, OUT lexeme text, OUT positions smallint[], OUT weights text)

setof record

把一个tsvector扩展成一组行

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

(cat,{3},{D}) ...

相关内容

热门资讯

7月开门红,后市关注这些机会!... 本周,A股迎来7月开门红,三大股指震荡收涨,沪指盘中续创今年以来新高。展望后市,业内机构认为,市场有...
15位长“700”号段号码将问... 点外卖、收快递、打网约车时,你是否担心自己的手机号码被别有用心的人利用,造成个人信息泄露和电信网络诈...
最后一张签证影评 最后一张签证影评旅游签证都是三个月,没有长期的,三个月一签,一般签一次 第二次就不会给你签旅游签了
友谊可以长久吗? 友谊可以长久吗?可以是很久甚至是一辈子哦!我认为真正的友谊是好朋友间的相互包容、理解.友谊是懂得相互...
数码宝贝5国语中第几集是仙女兽... 数码宝贝5国语中第几集是仙女兽进化的貌似是第四部吧,如果是的话,第4集 不要小看我!女斗士仙女兽第1...
记载 记叙 记录 记述 是什么... 记载 记叙 记录 记述 是什么意思,四个词有什么区别?都可以当动词和名词用啊,记载和记述可以通用。记...
一鸣惊人,事业高升,效果显著,... 一鸣惊人,事业高升,效果显著,心想事成的星座有哪几个呢?有天秤座,天蝎座,摩羯座,双子座,双鱼座。这...
新版《中国高速铁路》,中英双语... 转自:千龙网7月6日,新版《中国高速铁路》中英双语对照图书在北京出版发行。该书系统记录了中国高铁从蓄...
你们相信这个世界上有真爱吗?为... 你们相信这个世界上有真爱吗?为什么?有啊,爱情还是会有的真爱,有但很少很少了,只有两人都珍惜对方才会...
表姐的孩子表妹叫什么 表姐的孩子表妹叫什么表姐的孩子表妹叫什么这位知友,表姐的孩子是表妹的表外甥(女),表妹是表姐孩子的表...