Halaman ini belum tersedia dalam bahasa lokal Anda. Kami berusaha keras untuk menambahkan lebih banyak versi bahasa. Terima kasih atas dukungan Anda.

Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Situation Awareness
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
Software Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive

Text Search Functions and Operators

Updated on 2024-05-21 GMT+08:00

Text Search Operators

  • @@

    Description: Specifies whether the tsvector-typed words match the tsquery-typed words.

    Example:

    1
    2
    3
    4
    5
    gaussdb=# SELECT to_tsvector('fat cats ate rats') @@ to_tsquery('cat & rat') AS RESULT;
     result 
    --------
     t
    (1 row)
    
  • @@@

    Description: Synonym for @@

    Example:

    1
    2
    3
    4
    5
    gaussdb=# SELECT to_tsvector('fat cats ate rats') @@@ to_tsquery('cat & rat') AS RESULT;
     result 
    --------
     t
    (1 row)
    
  • ||

    Description: Connects two tsvector-typed words.

    Example:

    1
    2
    3
    4
    5
    gaussdb=# SELECT 'a:1 b:2'::tsvector || 'c:1 d:2 b:3'::tsvector AS RESULT;
              result           
    ---------------------------
     'a':1 'b':2,5 'c':3 'd':4
    (1 row)
    
  • &&

    Description: Performs the AND operation on two tsquery-typed words.

    Example:

    1
    2
    3
    4
    5
    gaussdb=# SELECT 'fat | rat'::tsquery && 'cat'::tsquery AS RESULT;
              result           
    ---------------------------
     ( 'fat' | 'rat' ) & 'cat'
    (1 row)
    
  • ||

    Description: Performs the OR operation on two tsquery-typed words.

    Example:

    1
    2
    3
    4
    5
    gaussdb=# SELECT 'fat | rat'::tsquery || 'cat'::tsquery AS RESULT;
              result           
    ---------------------------
     ( 'fat' | 'rat' ) | 'cat'
    (1 row)
    
  • !!

    Description: Not a tsquery-typed word.

    Example:

    1
    2
    3
    4
    5
    gaussdb=# SELECT !! 'cat'::tsquery AS RESULT;
     result 
    --------
     !'cat'
    (1 row)
    
  • @>

    Description: Specifies whether a tsquery-typed word contains another tsquery-typed word.

    Example:

    1
    2
    3
    4
    5
    gaussdb=# SELECT 'cat'::tsquery @> 'cat & rat'::tsquery AS RESULT;
     result 
    --------
     f
    (1 row)
    
  • <@

    Description: Specifies whether a tsquery-typed word is contained in another tsquery-typed word.

    Example:

    1
    2
    3
    4
    5
    gaussdb=# SELECT 'cat'::tsquery <@ 'cat & rat'::tsquery AS RESULT;
     result 
    --------
     t
    (1 row)
    

In addition to the preceding operators, the ordinary B-tree comparison operators (including = and <) are defined for types tsvector and tsquery.

Text Search Functions

  • get_current_ts_config()

    Description: Obtains default text search configurations.

    Return type: regconfig

    Example:

    1
    2
    3
    4
    5
    gaussdb=# SELECT get_current_ts_config();
     get_current_ts_config 
    -----------------------
     english
    (1 row)
    
  • length(tsvector)

    Description: Specifies the number of tsvector-typed words.

    Return type: integer

    Example:

    1
    2
    3
    4
    5
    gaussdb=# SELECT length('fat:2,4 cat:3 rat:5A'::tsvector);
     length 
    --------
          3
    (1 row)
    
  • numnode(tsquery)

    Description: Specifies the number of tsquery-typed words plus operators.

    Return type: integer

    Example:

    1
    2
    3
    4
    5
    gaussdb=# SELECT numnode('(fat & rat) | cat'::tsquery);
     numnode 
    ---------
           5
    (1 row)
    
  • plainto_tsquery([ config regconfig , ] query text)

    Description: Generates tsquery-typed words without punctuations.

    Return type: tsquery

    Example:

    1
    2
    3
    4
    5
    gaussdb=# SELECT plainto_tsquery('english', 'The Fat Rats');
     plainto_tsquery 
    -----------------
     'fat' & 'rat'
    (1 row)
    
  • querytree(query tsquery)

    Description: Obtains the indexable part of a tsquery-typed word.

    Return type: text

    Example:

    1
    2
    3
    4
    5
    gaussdb=# SELECT querytree('foo & ! bar'::tsquery);
     querytree 
    -----------
     'foo'
    (1 row)
    
  • setweight(tsvector, "char")

    Description: Assigns weight to each element of tsvector.

    Return type: tsvector

    Example:

    1
    2
    3
    4
    5
    gaussdb=# SELECT setweight('fat:2,4 cat:3 rat:5B'::tsvector, 'A');
               setweight           
    -------------------------------
     'cat':3A 'fat':2A,4A 'rat':5A
    (1 row)
    
  • strip(tsvector)

    Description: Removes positions and weights from tsvector.

    Return type: tsvector

    Example:

    1
    2
    3
    4
    5
    gaussdb=# SELECT strip('fat:2,4 cat:3 rat:5A'::tsvector);
           strip       
    -------------------
     'cat' 'fat' 'rat'
    (1 row)
    
  • to_tsquery([ config regconfig , ] query text)

    Description: Normalizes words and converts them to tsquery.

    Return type: tsquery

    Example:

    1
    2
    3
    4
    5
    gaussdb=# SELECT to_tsquery('english', 'The & Fat & Rats');
      to_tsquery   
    ---------------
     'fat' & 'rat'
    (1 row)
    
  • to_tsvector([ config regconfig , ] document text)

    Description: Reduces document text to tsvector.

    Return type: tsvector

    Example:

    1
    2
    3
    4
    5
    gaussdb=# SELECT to_tsvector('english', 'The Fat Rats');
       to_tsvector   
    -----------------
     'fat':2 'rat':3
    (1 row)
    
  • to_tsvector_for_batch([ config regconfig , ] document text)

    Description: Reduces document text to tsvector.

    Return type: tsvector

    Example:

    1
    2
    3
    4
    5
    gaussdb=# SELECT to_tsvector_for_batch('english', 'The Fat Rats');
       to_tsvector   
    -----------------
     'fat':2 'rat':3
    (1 row)
    
  • ts_headline([ config regconfig, ] document text, query tsquery [, options text ])

    Description: Highlights a query match.

    Return type: text

    Example:

    1
    2
    3
    4
    5
    gaussdb=# SELECT ts_headline('x y z', 'z'::tsquery);
     ts_headline  
    --------------
     x y <b>z</b>
    (1 row)
    
  • ts_rank([ weights float4[], ] vector tsvector, query tsquery [, normalization integer ])

    Description: Ranks document for query.

    Return type: float4

    Example:

    1
    2
    3
    4
    5
    gaussdb=# SELECT ts_rank('hello world'::tsvector, 'world'::tsquery);
     ts_rank  
    ----------
     .0607927
    (1 row)
    
  • ts_rank_cd([ weights float4[], ] vector tsvector, query tsquery [, normalization integer ])

    Description: Ranks document for query using cover density.

    Return type: float4

    Example:

    1
    2
    3
    4
    5
    gaussdb=# SELECT ts_rank_cd('hello world'::tsvector, 'world'::tsquery);
     ts_rank_cd 
    ------------
              .0
    (1 row)
    
  • ts_rewrite(query tsquery, target tsquery, substitute tsquery)

    Description: Replaces tsquery-typed word.

    Return type: tsquery

    Example:

    1
    2
    3
    4
    5
    gaussdb=# SELECT ts_rewrite('a & b'::tsquery, 'a'::tsquery, 'foo|bar'::tsquery);
           ts_rewrite        
    -------------------------
     'b' & ( 'foo' | 'bar' )
    (1 row)
    
  • ts_rewrite(query tsquery, select text)

    Description: Replaces tsquery data in the target with the result of a SELECT command.

    Return type: tsquery

    Example:

    1
    2
    3
    4
    5
    gaussdb=# SELECT ts_rewrite('world'::tsquery, 'select ''world''::tsquery, ''hello''::tsquery');
     ts_rewrite 
    ------------
     'hello'
    (1 row)
    

Text Search Debugging Functions

  • ts_debug([ config regconfig, ] document text, OUT alias text, OUT description text, OUT token text, OUT dictionaries regdictionary[], OUT dictionary regdictionary, OUT lexemes text[])

    Description: Tests a configuration.

    Return type: SETOF record

    Example:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    gaussdb=# SELECT ts_debug('english', 'The Brightest supernovaes');
                                         ts_debug                                      
    -----------------------------------------------------------------------------------
     (asciiword,"Word, all ASCII",The,{english_stem},english_stem,{})
     (blank,"Space symbols"," ",{},,)
     (asciiword,"Word, all ASCII",Brightest,{english_stem},english_stem,{brightest})
     (blank,"Space symbols"," ",{},,)
     (asciiword,"Word, all ASCII",supernovaes,{english_stem},english_stem,{supernova})
    (5 rows)
    
  • ts_lexize(dict regdictionary, token text)

    Description: Tests a data dictionary.

    Return type: text[]

    Example:

    1
    2
    3
    4
    5
    gaussdb=# SELECT ts_lexize('english_stem', 'stars');
     ts_lexize 
    -----------
     {star}
    (1 row)
    
  • ts_parse(parser_name text, document text, OUT tokid integer, OUT token text)

    Description: Tests a parser.

    Return type: SETOF record

    Example:

    1
    2
    3
    4
    5
    6
    7
    8
    gaussdb=# SELECT ts_parse('default', 'foo - bar');
     ts_parse  
    -----------
     (1,foo)
     (12," ")
     (12,"- ")
     (1,bar)
    (4 rows)
    
  • ts_parse(parser_oid oid, document text, OUT tokid integer, OUT token text)

    Description: Tests a parser.

    Return type: SETOF record

    Example:

    1
    2
    3
    4
    5
    6
    7
    8
    gaussdb=# SELECT ts_parse(3722, 'foo - bar');
     ts_parse  
    -----------
     (1,foo)
     (12," ")
     (12,"- ")
     (1,bar)
    (4 rows)
    
  • ts_token_type(parser_name text, OUT tokid integer, OUT alias text, OUT description text)

    Description: Obtains token types defined by a parser.

    Return type: SETOF record

    Example:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    gaussdb=# SELECT ts_token_type('default');
                            ts_token_type                         
    --------------------------------------------------------------
     (1,asciiword,"Word, all ASCII")
     (2,word,"Word, all letters")
     (3,numword,"Word, letters and digits")
     (4,email,"Email address")
     (5,url,URL)
     (6,host,Host)
     (7,sfloat,"Scientific notation")
     (8,version,"Version number")
     (9,hword_numpart,"Hyphenated word part, letters and digits")
     (10,hword_part,"Hyphenated word part, all letters")
     (11,hword_asciipart,"Hyphenated word part, all ASCII")
     (12,blank,"Space symbols")
     (13,tag,"XML tag")
     (14,protocol,"Protocol head")
     (15,numhword,"Hyphenated word, letters and digits")
     (16,asciihword,"Hyphenated word, all ASCII")
     (17,hword,"Hyphenated word, all letters")
     (18,url_path,"URL path")
     (19,file,"File or path name")
     (20,float,"Decimal notation")
     (21,int,"Signed integer")
     (22,uint,"Unsigned integer")
     (23,entity,"XML entity")
    (23 rows)
    
  • ts_token_type(parser_oid oid, OUT tokid integer, OUT alias text, OUT description text)

    Description: Obtains token types defined by a parser.

    Return type: SETOF record

    Example:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    gaussdb=# SELECT ts_token_type(3722);
                            ts_token_type                         
    --------------------------------------------------------------
     (1,asciiword,"Word, all ASCII")
     (2,word,"Word, all letters")
     (3,numword,"Word, letters and digits")
     (4,email,"Email address")
     (5,url,URL)
     (6,host,Host)
     (7,sfloat,"Scientific notation")
     (8,version,"Version number")
     (9,hword_numpart,"Hyphenated word part, letters and digits")
     (10,hword_part,"Hyphenated word part, all letters")
     (11,hword_asciipart,"Hyphenated word part, all ASCII")
     (12,blank,"Space symbols")
     (13,tag,"XML tag")
     (14,protocol,"Protocol head")
     (15,numhword,"Hyphenated word, letters and digits")
     (16,asciihword,"Hyphenated word, all ASCII")
     (17,hword,"Hyphenated word, all letters")
     (18,url_path,"URL path")
     (19,file,"File or path name")
     (20,float,"Decimal notation")
     (21,int,"Signed integer")
     (22,uint,"Unsigned integer")
     (23,entity,"XML entity")
    (23 rows)
    
  • ts_stat(sqlquery text, [ weights text, ] OUT word text, OUT ndoc integer, OUT nentry integer)

    Description: Obtains statistics of a tsvector column.

    Return type: SETOF record

    Example:

    1
    2
    3
    4
    5
    6
    gaussdb=# SELECT ts_stat('select ''hello world''::tsvector');
       ts_stat   
    -------------
     (world,1,1)
     (hello,1,1)
    (2 rows)
    

Kami menggunakan cookie untuk meningkatkan kualitas situs kami dan pengalaman Anda. Dengan melanjutkan penelusuran di situs kami berarti Anda menerima kebijakan cookie kami. Cari tahu selengkapnya

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback