I'm trying to use Full Text Search with Chinese characters using a postgres (9.6.1) FTS extension ZHParser.

Following some of the examples here, I wanted to select my title column and match the title to_tsvector to the query string to_tsquery with:

select title from table1 where 
to_tsvector('testzhcfg',title) @@ to_tsquery('testzhcfg','饭'); // 饭  = rice

table1 schema:

id  | title   
1   | 饭     
2   | 吃饭    
3   | 我喜欢吃饭 
4   | 谢谢    
5   | 淘气    

This gives:

NOTICE:  text-search query contains only stop words or doesn't contain lexemes, ignored
(0 rows)

I expected results:



Since 饭 (rice) is present in each.

This article talks about the issue, and recommends ensuring UTF8 encoded DB. I've ensured the table is UTF8:

mydatabase=# \l
                                             List of databases
      Name      |     Owner      | Encoding |   Collate   |    Ctype    |         Access privileges         
 mydatabase     | myname         | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =Tc/myname               +
                |                |          |             |             | myname=CTc/myname

What other configurations need to be made to allow FTS to work with non-latin, specifically Chinese, characters?

Even more, if I search through the stop words of the configurations in /usr/local/share/postgresql/tsearch_data, I do not see 饭 listed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.