PostgreSQL Asian language support for full text search using ICU (and also updating pg_trgm)

From: Chanon Sajjamanochai <chanon(dot)s(at)gmail(dot)com>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: PostgreSQL Asian language support for full text search using ICU (and also updating pg_trgm)
Date: 2019-05-01 01:55:50
Message-ID: CAEV3FNPU8hU_hi=0+QNAbEkc-uO8-K9PB3aAChdmcCyPfWX6rg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

Hello,

Currently PostgreSQL doesn't support full text search natively for many
Asian languages such as Chinese, Japanese and others. These languages are
used by a large portion of the population of the world.

The two key modules that could be modified to support Asian languages are
the full text search module (including tsvector) and pg_trgm.

I would like to propose that this support be added to PostgreSQL.

For full text search, PostgreSQL could add a new parser (
https://www.postgresql.org/docs/9.2/textsearch-parsers.html) that
implements ICU word tokenization. This should be a lot more easier than
before now that PostgreSQL itself already includes ICU dependencies for
other things.

Then allow the ICU parser to be chosen at run-time (via a run-time config
or an option to to_tsvector). That is all that is needed to support full
text search for many more Asian languages natively in PostgreSQL such as
Chinese, Japanese and Thai.

For example Elastic Search implements this using its ICU Tokenizer plugin:
https://www.elastic.co/guide/en/elasticsearch/guide/current/icu-tokenizer.html

Some information about the related APIs in ICU for this are at:
http://userguide.icu-project.org/boundaryanalysis

Another simple improvement that would give another option for searching for
Asian languages is to add a run-time setting for pg_trgm that would tell it
to not drop non-ascii characters, as currently it only indexes ascii
characters and thus all Asian language characters are dropped.

I emphasize 'run-time setting' because when using PostgreSQL via a
Database-As-A-Service service provider, most of the time it is not possible
to change the config files, recompile sources, or add any new extensions.

PostgreSQL is an awesome project and probably the best RDBMS right now. I
hope the maintainers consider this suggestion.

Best Regards,
Chanon

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Charlin Barak 2019-05-01 13:01:40 Oracle number to PostgreSQL
Previous Message Adrian Klaver 2019-04-30 22:25:38 Re: ERROR: operator does not exist: timestamp without time zone + integer

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2019-05-01 02:09:51 Re: Adding a test for speculative insert abort case
Previous Message Fabien COELHO 2019-05-01 01:53:41 Re: performance regression when filling in a table