Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id AA87117C2104 for ; Wed, 20 Jun 2012 23:53:19 -0300 (ADT) Received: from mail-gh0-f174.google.com ([209.85.160.174]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1ShXWI-0001Oa-W4 for pgsql-sql@postgresql.org; Thu, 21 Jun 2012 02:53:19 +0000 Received: by ghrr11 with SMTP id r11so116109ghr.19 for ; Wed, 20 Jun 2012 19:53:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding :x-gm-message-state; bh=+vP3ZJZl0vXtPk51++BvinJt7Kogxdr6hL4MBRfVnWQ=; b=YhEMYoUMSkq4JI9Bn6Ec0eqbCcbxMUvvqE8YRWEfXQyklr/cz665glaOYFHnXjben6 cFqxOgzHtOlIlLpQ9IDxRMhwCW/rIYdoGoasoaaDIaJW+A920/+6rT2nRbXkVInibENX ROQjJcDjOD16P94jq9Lng9X+Y1LNJba8djIJp/XCsqJFFDbKNp0YQNbM+cC+YsRaCod1 76XdIO0wbAIJFHzFLojqe9XrWvfW1P67WE8VpYrq50oqUp6DeBfJKqkP4ouHbLBADFv9 yqP9vpCOt+MKMAX8H8mrHug3fSspoe3kfU5ptnP+o6XXrtReIYTSxL+GyeV5Q91LkIA5 TOnQ== Received: by 10.50.171.105 with SMTP id at9mr6262569igc.28.1340247186290; Wed, 20 Jun 2012 19:53:06 -0700 (PDT) Received: from ayaki.localdomain (124-169-169-118.dyn.iinet.net.au. [124.169.169.118]) by mx.google.com with ESMTPS id ga6sm16674416igc.2.2012.06.20.19.53.03 (version=SSLv3 cipher=OTHER); Wed, 20 Jun 2012 19:53:05 -0700 (PDT) Message-ID: <4FE28C8C.9080300@ringerc.id.au> Date: Thu, 21 Jun 2012 10:53:00 +0800 From: Craig Ringer User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120605 Thunderbird/13.0 MIME-Version: 1.0 To: Andreas CC: pgsql-sql@postgresql.org Subject: Re: Is there a similarity-function that minds national charsets? References: <4FE1FAAF.3090004@gmx.net> In-Reply-To: <4FE1FAAF.3090004@gmx.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Gm-Message-State: ALoCoQnTqZAQbfEYb5PHhA5B9TjD1c8nQvKsrvFOk5/c5QclRSm4cpLp/28oKVPFBgqWI19We8Ar X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201206/63 X-Sequence-Number: 36717 On 06/21/2012 12:30 AM, Andreas wrote: > Hi, > > Is there a similarity-function that minds national charsets? > > Over here we've got some special cases that screw up the results on > similarity(). > > Our characters: ä, ö, ü, ß > could as well be written as: ae, oe, ue, ss > > e.g. > > select similarity ( 'Müller', 'Mueller' ) > results to: 0.363636 > > In normal cases everything below 0.5 would be to far apart to be > considered a match. That's not just charset aware, that's looking for awareness of language-and-dialect specific transliteration rules for representing accented chars in 7-bit ASCII. My understanding was that these rules and conventions vary and are specific to each language - or even region. tsearch2 has big language dictionaries to try to handle some issues like this (though I don't know about this issue specifically). It's possible you could extend the tsearch2 dictionaries with synonyms, possibly algorithmically generated. If you have what you consider to be an acceptable 1:1 translation rule you could build a functional index on it and test against that, eg: CREATE INDEX blah ON thetable ( (flatten_accent(target_column) ); SELECT similarity( flatten_accent('Müller'), target_column ); Note that the flatten_accent function must be IMMUTABLE and can't access or refer to data in other tables, columns, etc nor SET (GUC) variables that might change at runtime. -- Craig Ringer