Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1ZpCwF-0001th-FU for pgsql-bugs@arkaria.postgresql.org; Thu, 22 Oct 2015 10:17:39 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1ZpCwE-0000V9-9a for pgsql-bugs@arkaria.postgresql.org; Thu, 22 Oct 2015 10:17:38 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1ZpCvc-0008FV-Hb for pgsql-bugs@postgresql.org; Thu, 22 Oct 2015 10:17:00 +0000 Received: from newmail.postgrespro.ru ([93.174.131.138] helo=mail.postgrespro.ru) by magus.postgresql.org with esmtp (Exim 4.84) (envelope-from ) id 1ZpCvX-0004g8-S8 for pgsql-bugs@postgresql.org; Thu, 22 Oct 2015 10:16:58 +0000 Received: from [192.168.27.188] (unknown [192.168.27.1]) by mail.postgrespro.ru (Postfix) with ESMTPSA id 925D821C3F44; Thu, 22 Oct 2015 13:16:54 +0300 (MSK) Subject: Re: BUG #13690: Full Text Search with spanish dictionary cannot find some words To: Tom Lane , vtamara@pasosdeJesus.org References: <20151020110857.3017.63066@wrigleys.postgresql.org> <33158.1445358098@sss.pgh.pa.us> Cc: pgsql-bugs@postgresql.org From: Artur Zakirov Message-ID: <5628B796.1080305@postgrespro.ru> Date: Thu, 22 Oct 2015 13:16:54 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <33158.1445358098@sss.pgh.pa.us> Content-Type: text/plain; charset=windows-1251; format=flowed Content-Transfer-Encoding: 8bit X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org 20.10.2015 19:21, Tom Lane пишет: > This is because you didn't adjust the wildcard search pattern for the > different stemming rules used in Spanish. Look at the to_tsvector and > to_tsquery results: > > regression=# SELECT to_tsvector('english', nombre) , to_tsquery('english','politi:*') from cat; > to_tsvector | to_tsquery > -------------------------+------------ > 'politica':1 'social':2 | 'politi':* > (1 row) > > regression=# SELECT to_tsvector('spanish', nombre) , to_tsquery('spanish','politi:*') from cat; > to_tsvector | to_tsquery > ----------------------+------------ > 'polit':1 'social':2 | 'politi':* > (1 row) > > I don't know enough Spanish to follow the reasoning for stemming > "politica" as "polit" rather than something else; but I do see that > "politi" is not reduced to "polit", which is fairly reasonable since > that's not a word. "politi:*" will match anything whose stemmed > version starts with "politi", but that's too long ... Tom is right. You cannot change stemming rules used in Spanish. But on the other hand you can create the synonym dictionary. First, you need create file $SHAREDIR/tsearch_data/spanish.syn with the following entry: politi polit Then execute the following script: CREATE TEXT SEARCH DICTIONARY spanish_synonym ( TEMPLATE = synonym, SYNONYMS = spanish ); ALTER TEXT SEARCH CONFIGURATION spanish ALTER MAPPING FOR asciiword WITH spanish_synonym, spanish_stem; After that the following query: SELECT COUNT(*) FROM cat WHERE to_tsvector('spanish', nombre) @@ to_tsquery('spanish', 'politi:*'); will return 1. You can read about synonym dictionary in the documentation: http://www.postgresql.org/docs/devel/static/textsearch-dictionaries.html -- Artur Zakirov Postgres Professional: http://www.postgrespro.com Russian Postgres Company -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs