Question Details

No question body available.

Tags

postgresql full-text-search polardb

Answers (1)

February 28, 2026 Score: 0 Rep: 258,574 Quality: Medium Completeness: 60%

A disclaimer: I know nothing about Chinese.

The problem here is that full-text search is designed to find whole words in a larger text. Now in languages that use letters, words consist of several letters and are separated by spaces or punctuation characters. There are no spaces in your text, and consequently PostgreSQL full-text search (which has no dedicated support for Chinese) treats your texts as a single words.

You can see that with the function tsdebug():

SELECT * FROM tsdebug('simple', '这是一款最新款的苹果智能手机,支持5G网络');

-[ RECORD 1 ]+------------------------------- alias | word description | Word, all letters token | 这是一款最新款的苹果智能手机 dictionaries | {simple} dictionary | simple lexemes | {这是一款最新款的苹果智能手机} -[ RECORD 2 ]+------------------------------- alias | blank description | Space symbols token | , dictionaries | {} dictionary | lexemes | -[ RECORD 3 ]+------------------------------- alias | numword description | Word, letters and digits token | 支持5G网络 dictionaries | {simple} dictionary | simple lexemes | {支持5g网络}

I used the "simple" text search configuration here, but the result would be the same with any other text search configuration. You see that the full-text search parser treats your string as two words, separated by a comma. (If that comma is recognized as a punctuation character or not depends on the lcctype setting of your database — if lcctype were "C", the parser would see the entire string as a single word.)

What you seem to need is substring search. The following query produces the result you would like to see:

SELECT id, name, description FROM products WHERE description LIKE '%苹果%';

-[ RECORD 1 ]----------------------------------------- id | 1 name | 苹果手机 description | 这是一款最新款的苹果智能手机,支持5G网络

If you need good performance for a query like that, the only thing that can help is a trigram index:

CREATE EXTENSION IF NOT EXISTS pgtrgm SCHEMA public;

CREATE INDEX products
patternidx ON products USING gin (description gintrgm_ops);