From: Tom Lane <tgl@sss.pgh.pa.us>
To: Florents Tselai <florents.tselai@gmail.com>
Cc: pgsql-general <pgsql-general@lists.postgresql.org>
Subject: Re: Multilang text search. Is this correct?
Date: Thu, 30 Mar 2023 14:28:58 -0400
Message-ID: <257315.1680200938@sss.pgh.pa.us> (raw)
In-Reply-To: <92C5D7E0-A9C6-441B-80D8-C86F80AB7F30@gmail.com>
References: <92C5D7E0-A9C6-441B-80D8-C86F80AB7F30@gmail.com>
Florents Tselai <florents.tselai@gmail.com> writes:
> In my table (mix of text and jsonb columns ) I have text in multiple languages.
> I’d like search in all the possible regconfigs, so I’ve come up with the following recipe:
> CREATE FUNCTION to_tsvector_multilang(text) RETURNS tsvector AS
> $$
> SELECT to_tsvector('english', $1) ||
> to_tsvector('greek', $1) ||
> to_tsvector('simple', $1)
> $$ LANGUAGE sql IMMUTABLE;
> Looks like it’s working as expected from my prelim tests, but anyone seeing any potential pitfalls?
Well, it'll work for some value of "work", but your tsvectors and
associated indexes will be bloated, and you're likely to get false
matches. (For example, common words like "the" will get indexed
and treated as matchable unless they're stopwords in all three
configurations.)
The usual compromise is to use just one config --- either 'simple',
or a specific language if you have a preponderance of data in that
language --- and tolerate the fact that searches won't be too bright
about things like reducing stemmed words.
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: tgl@sss.pgh.pa.us, florents.tselai@gmail.com
Subject: Re: Multilang text search. Is this correct?
In-Reply-To: <257315.1680200938@sss.pgh.pa.us>
References: <92C5D7E0-A9C6-441B-80D8-C86F80AB7F30@gmail.com> <257315.1680200938@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox