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
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

CREATE TEXT SEARCH DICTIONARY

Updated on 2023-10-23 GMT+08:00

Function

CREATE TEXT SEARCH DICTIONARY creates a full-text retrieval dictionary. A dictionary is used to identify and process particular words during full-text retrieval.

Dictionaries are created by using predefined templates (defined in the PG_TS_TEMPLATE system catalog). Five types of dictionaries can be created, Simple, Ispell, Synonym, Thesaurus, and Snowball. These dictionaries are used to handle different types of tasks.

Precautions

  • A user with the SYSADMIN permission can create a dictionary. Then, the user automatically becomes the owner of the dictionary.
  • A dictionary cannot be created in pg_temp mode.
  • After a dictionary is created or modified, any modification to the customized dictionary definition file will not affect the dictionary in the database. To make such modifications take effect in the dictionary in the database, run the ALTER statement to update the definition file of the dictionary.

Syntax

CREATE TEXT SEARCH DICTIONARY name (
    TEMPLATE = template
    [, option = value [, ... ]]
);

Parameter Description

  • name

    Specifies the name of a dictionary to be created. (If you do not specify a schema name, the dictionary will be created in the current schema.)

    Value range: a string, which complies with the identifier naming convention. A value can contain a maximum of 63 characters.

  • template

    Specifies a template name.

    Value range: templates (Simple, Synonym, Thesaurus, Ispell, and Snowball) defined in the PG_TS_TEMPLATE system catalog

  • option

    Specifies a parameter name. Each type of dictionaries has a template containing their custom parameters. Parameters function in a way irrelevant to their setting sequence.

    • Parameters for a Simple dictionary
      • STOPWORDS

        Specifies the name of a file listing stop words. The default file name extension is .stop. In the file, each line defines a stop word. Dictionaries will ignore blank lines and spaces in the file and convert stop-word phrases into lowercase.

      • ACCEPT

        Specifies whether to accept a non-stop word as recognized. Default value: true

        If ACCEPT=true is set for a Simple dictionary, no token will be passed to subsequent dictionaries. In this case, you are advised to place the Simple dictionary at the end of the dictionary list. If ACCEPT=false is set, you are advised to place the Simple dictionary before at least one dictionary in the list.

      • FILEPATH

        Specifies the directory for storing dictionary files. The directory can be a local directory or an OBS directory. (The OBS directory can be specified only in security mode. You can add the securitymode option during startup to enter the security mode.) The local directory format is file://absolute_path. The OBS directory format is obs://bucket_name/path accesskey=ak secretkey=sk region=rg. The default value is the directory where predefined dictionary files are located. If any of the FILEPATH and STOPWORDS parameters is specified, the other one must also be specified.

    • Parameters for a Synonym dictionary
      • SYNONYM

        Specifies the name of the definition file for a Synonym dictionary. The default file name extension is .syn.

        The file is a list of synonyms. Each line is in the format of token synonym, that is, token and its synonym separated by a space.

      • CASESENSITIVE

        Specifies whether tokens and their synonyms are case sensitive. The default value is false, indicating that tokens and synonyms in dictionary files will be converted into lowercase. If this parameter is set to true, they will not be converted into lowercase.

      • FILEPATH

        Specifies the directory for storing Synonym dictionary files. The directory can be a local directory or an OBS directory. (The OBS directory can be specified only in security mode. You can add the securitymode option during startup to enter the security mode.) The local directory format is file://absolute_path. The OBS directory format is obs://bucket_name/path accesskey=ak secretkey=sk region=rg. The default value is the directory where predefined dictionary files are located.

    • Parameters for a Thesaurus dictionary
      • DICTFILE

        Specifies the name of a dictionary definition file. The default file name extension is .ths.

        The file is a list of synonyms. Each line is in the format of sample words : indexed words. The colon (:) is used as a separator between a phrase and its substitute word. If multiple sample words are matched, the TZ selects the longest one.

      • DICTIONARY

        Specifies the name of a subdictionary used for word normalization. This parameter is mandatory and only one subdictionary name can be specified. The specified subdictionary must exist. It is used to identify and normalize input text before phrase matching.

        If an input word cannot be recognized by the subdictionary, an error will be reported. In this case, remove the word or update the subdictionary to make the word recognizable. In addition, an asterisk (*) can be placed at the beginning of an indexed word to skip the application of a subdictionary on it, but all sample words must be recognizable by the subdictionary.

        If the sample words defined in the dictionary file contain stop words defined in the subdictionary, use question marks (?) to replace them. Assume that a and the are stop words defined in the subdictionary.
        ? one ? two : swsw

        a one the two and the one a two will be matched and output as swsw.

      • FILEPATH

        Specifies the directory for storing dictionary definition files. The directory can be a local directory or an OBS directory. (The OBS directory can be specified only in security mode. You can add the securitymode option during startup to enter the security mode.) The local directory format is file://absolute_path. The OBS directory format is obs://bucket_name/path accesskey=ak secretkey=sk region=rg. The default value is the directory where predefined dictionary files are located.

    • Parameters for an Ispell dictionary
      • DICTFILE

        Specifies the name of a dictionary definition file. The default file name extension is .dict.

      • AFFFILE

        Specifies the name of an affix file. The default file name extension is .affix.

      • STOPWORDS

        Specifies the name of a file listing stop words. The default file name extension is .stop. The file content format is the same as that of the file for a Simple dictionary.

      • FILEPATH

        Specifies the directory for storing dictionary files. The directory can be a local directory or an OBS directory. (The OBS directory can be specified only in security mode. You can add the securitymode option during startup to enter the security mode.) The local directory format is file://absolute_path. The OBS directory format is obs://bucket_name/path accesskey=ak secretkey=sk region=rg. The default value is the directory where predefined dictionary files are located.

    • Parameters for a Snowball dictionary
      • LANGUAGE

        Specifies the name of a language whose stemming algorithm will be used. According to spelling rules in the language, the algorithm normalizes the variants of an input word into a basic word or a stem.

      • STOPWORDS

        Specifies the name of a file listing stop words. The default file name extension is .stop. The file content format is the same as that of the file for a Simple dictionary.

      • FILEPATH

        Specifies the directory for storing dictionary definition files. You can specify a local directory or an OBS directory. (The OBS directory can be specified only in security mode. You can enter the security mode by adding the securitymode option during startup.) The local directory format is file://absolute_path. The OBS directory format is obs://bucket_name/path accesskey=ak secretkey=sk region=rg. The default value is the directory where predefined dictionary files are located. If any of the FILEPATH and STOPWORDS parameters is specified, the other one must also be specified.

    NOTE:

    The name of a dictionary definition file can contain only lowercase letters, digits, and underscores (_).

  • value

    Specifies a parameter value. If the value is not an identifier or a number, enclose it with single quotation marks (''). You can also enclose identifiers and numbers.

Examples

See examples in Configuration Examples.

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback