Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id 87EADA684E0 for ; Mon, 21 May 2012 20:02:13 -0300 (ADT) Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1SWbcA-0002Gd-RM for pgsql-bugs@postgresql.org; Mon, 21 May 2012 23:02:12 +0000 Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id q4LN1vkC009099 for ; Mon, 21 May 2012 19:01:57 -0400 (EDT) To: pgsql-bugs@postgresql.org Subject: Re: BUG #6654: Full text search doesn't find europe In-reply-to: <201205220031.22557.andres@anarazel.de> References: <201205220031.22557.andres@anarazel.de> Comments: In-reply-to Andres Freund message dated "Tue, 22 May 2012 00:31:21 +0200" Date: Mon, 21 May 2012 19:01:57 -0400 Message-ID: <9098.1337641317@sss.pgh.pa.us> From: Tom Lane X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201205/130 X-Sequence-Number: 33101 Andres Freund writes: > On Monday, May 21, 2012 07:26:38 PM wbrana@gmail.com wrote: >> CREATE INDEX idx_post_text ON posts USING gin >> (to_tsvector('english'::regconfig, post_text::text)) >> select * from v_search WHERE to_tsvector('english', post_text) @@ 'europe' >> returns no rows, but >> select * from v_search WHERE to_tsvector('english', post_text) @@ 'japan' >> returns row with "Japan and Europe" > The problem is that youre using to_tsvector('english' for parsing the text but > don't specify the text yearch configuration for the query. The default english > configuration does stemming, the default_text_search_configuration obviously > not. > Try ... to_tsvector('english', post_text) @@ to_tsquery('english', 'europe') BTW, a good way to debug this sort of issue is to look at the actual tsvector and tsquery values. regression=# select to_tsvector('english', 'Japan and Europe'); to_tsvector --------------------- 'europ':3 'japan':1 (1 row) regression=# select to_tsquery('english', 'Japan'); to_tsquery ------------ 'japan' (1 row) regression=# select to_tsquery('english', 'Europe'); to_tsquery ------------ 'europ' (1 row) If you just cast 'europe' directly to tsquery, which is what's going to happen in the first example, you get the lexeme 'europe' which doesn't match 'europ'. regards, tom lane