<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://rt-wiki.bestpractical.com/index.php?action=history&amp;feed=atom&amp;title=PostgreSQLFullTextTrgm</id>
	<title>PostgreSQLFullTextTrgm - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://rt-wiki.bestpractical.com/index.php?action=history&amp;feed=atom&amp;title=PostgreSQLFullTextTrgm"/>
	<link rel="alternate" type="text/html" href="https://rt-wiki.bestpractical.com/index.php?title=PostgreSQLFullTextTrgm&amp;action=history"/>
	<updated>2026-08-21T21:54:54Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.41.1</generator>
	<entry>
		<id>https://rt-wiki.bestpractical.com/index.php?title=PostgreSQLFullTextTrgm&amp;diff=26594&amp;oldid=prev</id>
		<title>Phanousk: /* An experimental PostgreSQL full text trigram based setup */</title>
		<link rel="alternate" type="text/html" href="https://rt-wiki.bestpractical.com/index.php?title=PostgreSQLFullTextTrgm&amp;diff=26594&amp;oldid=prev"/>
		<updated>2018-07-13T13:05:27Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;An experimental PostgreSQL full text trigram based setup&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 09:05, 13 July 2018&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l13&quot;&gt;Line 13:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 13:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Read the page [[PostgreSQLFullText]] first! Changes are described bellow. You can use my script [[rt-mysql2pg]] to prepare database for full text without a tedious work.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Read the page [[PostgreSQLFullText]] first! Changes are described bellow. You can use my script [[rt-mysql2pg]] to prepare database for full text without a tedious work.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-added&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* Patch for SearchBuilder (I have placed the modified version into &amp;amp;lt;rt-prefix&amp;amp;gt;/local/lib/DBIx/SearchBuilder.pm.):&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* Patch for SearchBuilder (I have placed the modified version into &amp;amp;lt;rt-prefix&amp;amp;gt;/local/lib/DBIx/SearchBuilder.pm.):&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt; &lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;source lang=&quot;Perl&quot;&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  --- SearchBuilder.pm.orig	2011-03-24 16:26:16.000000000 +0100&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  --- SearchBuilder.pm.orig	2011-03-24 16:26:16.000000000 +0100&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  +++ SearchBuilder.pm	2011-03-30 17:11:18.000000000 +0200&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  +++ SearchBuilder.pm	2011-03-30 17:11:18.000000000 +0200&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l67&quot;&gt;Line 67:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 66:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;    &lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;    &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;       return ( $args{&amp;#039;ALIAS&amp;#039;} );&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;       return ( $args{&amp;#039;ALIAS&amp;#039;} );&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;/source&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* To prepare already converted [[PostgreSQL]] database run:&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* To prepare already converted [[PostgreSQL]] database run:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  rt-mysql2pg -v --dst-dsn dbi:Pg:dbname=rt3 --fulltext --vacuum&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;tt&amp;gt;&lt;/ins&gt;rt-mysql2pg -v --dst-dsn dbi:Pg:dbname=rt3 --fulltext --vacuum&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;/tt&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;-- zito&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;-- zito&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;!-- diff cache key bestpractical_mediawiki1459887241:diff:1.41:old-2637:rev-26594:php=table --&gt;
&lt;/table&gt;</summary>
		<author><name>Phanousk</name></author>
	</entry>
	<entry>
		<id>https://rt-wiki.bestpractical.com/index.php?title=PostgreSQLFullTextTrgm&amp;diff=2637&amp;oldid=prev</id>
		<title>Admin: 5 revisions imported</title>
		<link rel="alternate" type="text/html" href="https://rt-wiki.bestpractical.com/index.php?title=PostgreSQLFullTextTrgm&amp;diff=2637&amp;oldid=prev"/>
		<updated>2016-04-06T20:20:29Z</updated>

		<summary type="html">&lt;p&gt;5 revisions imported&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 16:20, 6 April 2016&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;4&quot; class=&quot;diff-notice&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;!-- diff cache key bestpractical_mediawiki1459887241:diff:1.41:old-2636:rev-2637 --&gt;
&lt;/table&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
	<entry>
		<id>https://rt-wiki.bestpractical.com/index.php?title=PostgreSQLFullTextTrgm&amp;diff=2636&amp;oldid=prev</id>
		<title>193.86.153.231 at 21:43, 9 April 2014</title>
		<link rel="alternate" type="text/html" href="https://rt-wiki.bestpractical.com/index.php?title=PostgreSQLFullTextTrgm&amp;diff=2636&amp;oldid=prev"/>
		<updated>2014-04-09T21:43:26Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Outdated}}&lt;br /&gt;
&lt;br /&gt;
= RT 4 has built in native full text support for PostgreSQL =&lt;br /&gt;
&lt;br /&gt;
= An experimental PostgreSQL full text trigram based setup =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
please look at https://github.com/zito/rt-pgsql-fttrgm ... I will cleanup this page when i spare some free time. Thanks&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This article describes a setup of [[PostgreSQL]] full text in a non native mode using trigrams based matching. [[PostgreSQL]] full text can&amp;#039;t be used for substring searching in standard way. Version 8.4.x supports prefix matching, but it is still not sufficient for me. Inspired by http://kaiv.wordpress.com/2007/12/11/postgresql-substring-search/ and using know-how from [[PostgreSQLFullText]] I&amp;#039;m trying a fusion now :).&lt;br /&gt;
&lt;br /&gt;
Read the page [[PostgreSQLFullText]] first! Changes are described bellow. You can use my script [[rt-mysql2pg]] to prepare database for full text without a tedious work.&lt;br /&gt;
&lt;br /&gt;
* Patch for SearchBuilder (I have placed the modified version into &amp;amp;lt;rt-prefix&amp;amp;gt;/local/lib/DBIx/SearchBuilder.pm.):&lt;br /&gt;
&lt;br /&gt;
 --- SearchBuilder.pm.orig	2011-03-24 16:26:16.000000000 +0100&lt;br /&gt;
 +++ SearchBuilder.pm	2011-03-30 17:11:18.000000000 +0200&lt;br /&gt;
 @@ -932,11 +932,33 @@&lt;br /&gt;
  &lt;br /&gt;
      }&lt;br /&gt;
  &lt;br /&gt;
 -    my $clause = {&lt;br /&gt;
 +    my @clause = ( {&lt;br /&gt;
          field =&amp;gt; $QualifiedField,&lt;br /&gt;
          op =&amp;gt; $args{&amp;#039;OPERATOR&amp;#039;},&lt;br /&gt;
          value =&amp;gt; $args{&amp;#039;VALUE&amp;#039;},&lt;br /&gt;
 -    };&lt;br /&gt;
 +    } );&lt;br /&gt;
 +&lt;br /&gt;
 +    # Use FULLTEXT for large Attachments.Content and&lt;br /&gt;
 +    # ObjectCustomFieldValues.Largecontent in PostgreSQL.&lt;br /&gt;
 +    if ( $QualifiedField =~ m/^(?: Attachments_\d+\.Content&lt;br /&gt;
 +		| ObjectCustomFieldValues_\d+\.Largecontent )$/xi) {&lt;br /&gt;
 +	if ( $args{&amp;#039;OPERATOR&amp;#039;} =~ m/^(?:NOT )?I?LIKE$/&lt;br /&gt;
 +		&amp;amp;&amp;amp; $args{&amp;#039;VALUE&amp;#039;} =~ m/^&amp;#039;%.*%&amp;#039;$/ ) {&lt;br /&gt;
 +	    my $not = lc(substr($args{&amp;#039;OPERATOR&amp;#039;}, 0, 3)) eq &amp;#039;not&amp;#039;;&lt;br /&gt;
 +	    my $value = $args{&amp;#039;VALUE&amp;#039;};&lt;br /&gt;
 +	    $value  =~ s/^&amp;#039;%(.*)%&amp;#039;$/&amp;#039;$1&amp;#039;/;&lt;br /&gt;
 +	    $value  = $not ? &amp;quot;(!! text_to_trgm_tsquery($value))&amp;quot; : &amp;quot;text_to_trgm_tsquery($value)&amp;quot;;&lt;br /&gt;
 +	    my $field = $QualifiedField;&lt;br /&gt;
 +	    $field =~ s/\.(?:Content|Largecontent)$/.trigrams/;&lt;br /&gt;
 +	    @clause = ( &amp;#039;(&amp;#039;,&lt;br /&gt;
 +		{&lt;br /&gt;
 +		    field =&amp;gt; $field,&lt;br /&gt;
 +		    op =&amp;gt; &amp;#039;@@&amp;#039;,&lt;br /&gt;
 +		    value =&amp;gt; $value,&lt;br /&gt;
 +		},&lt;br /&gt;
 +		&amp;#039;AND&amp;#039;, @clause, &amp;#039;)&amp;#039; );&lt;br /&gt;
 +	}&lt;br /&gt;
 +    }&lt;br /&gt;
  &lt;br /&gt;
      # Juju because this should come _AFTER_ the EA&lt;br /&gt;
      my @prefix;&lt;br /&gt;
 @@ -945,10 +967,10 @@&lt;br /&gt;
      }&lt;br /&gt;
  &lt;br /&gt;
      if ( lc( $args{&amp;#039;ENTRYAGGREGATOR&amp;#039;} || &amp;quot;&amp;quot; ) eq &amp;#039;none&amp;#039; || !@$restriction ) {&lt;br /&gt;
 -        @$restriction = (@prefix, $clause);&lt;br /&gt;
 +        @$restriction = (@prefix, @clause);&lt;br /&gt;
      }&lt;br /&gt;
      else {&lt;br /&gt;
 -        push @$restriction, $args{&amp;#039;ENTRYAGGREGATOR&amp;#039;}, @prefix, $clause;&lt;br /&gt;
 +        push @$restriction, $args{&amp;#039;ENTRYAGGREGATOR&amp;#039;}, @prefix, @clause;&lt;br /&gt;
      }&lt;br /&gt;
  &lt;br /&gt;
      return ( $args{&amp;#039;ALIAS&amp;#039;} );&lt;br /&gt;
&lt;br /&gt;
* To prepare already converted [[PostgreSQL]] database run:&lt;br /&gt;
&lt;br /&gt;
 rt-mysql2pg -v --dst-dsn dbi:Pg:dbname=rt3 --fulltext --vacuum&lt;br /&gt;
&lt;br /&gt;
-- zito&lt;/div&gt;</summary>
		<author><name>193.86.153.231</name></author>
	</entry>
	<entry>
		<id>https://rt-wiki.bestpractical.com/index.php?title=PostgreSQLFullTextTrgm&amp;diff=2634&amp;oldid=prev</id>
		<title>95.173.94.255: filter by trigrams (index) &amp; like (to remove false matches)</title>
		<link rel="alternate" type="text/html" href="https://rt-wiki.bestpractical.com/index.php?title=PostgreSQLFullTextTrgm&amp;diff=2634&amp;oldid=prev"/>
		<updated>2011-04-06T08:59:53Z</updated>

		<summary type="html">&lt;p&gt;filter by trigrams (index) &amp;amp; like (to remove false matches)&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;= An experimental PostgreSQL full text trigram based setup =&lt;br /&gt;
&lt;br /&gt;
This article describes a setup of [[PostgreSQL]] full text in a non native mode using trigrams based matching. [[PostgreSQL]] full text can&amp;#039;t be used for substring searching in standard way. Version 8.4.x supports prefix matching, but it is still not sufficient for me. Inspired by http://kaiv.wordpress.com/2007/12/11/postgresql-substring-search/ and using know-how from [[PostgreSQLFullText]] I&amp;#039;m trying a fusion now :).&lt;br /&gt;
&lt;br /&gt;
Read the page [[PostgreSQLFullText]] first! Changes are described bellow. You can use my script [[rt-mysql2pg]] to prepare database for full text without a tedious work.&lt;br /&gt;
&lt;br /&gt;
* Patch for SearchBuilder (I have placed the modified version into &amp;amp;lt;rt-prefix&amp;amp;gt;/local/lib/DBIx/SearchBuilder.pm.):&lt;br /&gt;
&lt;br /&gt;
 --- SearchBuilder.pm.orig	2011-03-24 16:26:16.000000000 +0100&lt;br /&gt;
 +++ SearchBuilder.pm	2011-03-30 17:11:18.000000000 +0200&lt;br /&gt;
 @@ -932,11 +932,33 @@&lt;br /&gt;
  &lt;br /&gt;
      }&lt;br /&gt;
  &lt;br /&gt;
 -    my $clause = {&lt;br /&gt;
 +    my @clause = ( {&lt;br /&gt;
          field =&amp;gt; $QualifiedField,&lt;br /&gt;
          op =&amp;gt; $args{&amp;#039;OPERATOR&amp;#039;},&lt;br /&gt;
          value =&amp;gt; $args{&amp;#039;VALUE&amp;#039;},&lt;br /&gt;
 -    };&lt;br /&gt;
 +    } );&lt;br /&gt;
 +&lt;br /&gt;
 +    # Use FULLTEXT for large Attachments.Content and&lt;br /&gt;
 +    # ObjectCustomFieldValues.Largecontent in PostgreSQL.&lt;br /&gt;
 +    if ( $QualifiedField =~ m/^(?: Attachments_\d+\.Content&lt;br /&gt;
 +		| ObjectCustomFieldValues_\d+\.Largecontent )$/xi) {&lt;br /&gt;
 +	if ( $args{&amp;#039;OPERATOR&amp;#039;} =~ m/^(?:NOT )?I?LIKE$/&lt;br /&gt;
 +		&amp;amp;&amp;amp; $args{&amp;#039;VALUE&amp;#039;} =~ m/^&amp;#039;%.*%&amp;#039;$/ ) {&lt;br /&gt;
 +	    my $not = lc(substr($args{&amp;#039;OPERATOR&amp;#039;}, 0, 3)) eq &amp;#039;not&amp;#039;;&lt;br /&gt;
 +	    my $value = $args{&amp;#039;VALUE&amp;#039;};&lt;br /&gt;
 +	    $value  =~ s/^&amp;#039;%(.*)%&amp;#039;$/&amp;#039;$1&amp;#039;/;&lt;br /&gt;
 +	    $value  = $not ? &amp;quot;(!! text_to_trgm_tsquery($value))&amp;quot; : &amp;quot;text_to_trgm_tsquery($value)&amp;quot;;&lt;br /&gt;
 +	    my $field = $QualifiedField;&lt;br /&gt;
 +	    $field =~ s/\.(?:Content|Largecontent)$/.trigrams/;&lt;br /&gt;
 +	    @clause = ( &amp;#039;(&amp;#039;,&lt;br /&gt;
 +		{&lt;br /&gt;
 +		    field =&amp;gt; $field,&lt;br /&gt;
 +		    op =&amp;gt; &amp;#039;@@&amp;#039;,&lt;br /&gt;
 +		    value =&amp;gt; $value,&lt;br /&gt;
 +		},&lt;br /&gt;
 +		&amp;#039;AND&amp;#039;, @clause, &amp;#039;)&amp;#039; );&lt;br /&gt;
 +	}&lt;br /&gt;
 +    }&lt;br /&gt;
  &lt;br /&gt;
      # Juju because this should come _AFTER_ the EA&lt;br /&gt;
      my @prefix;&lt;br /&gt;
 @@ -945,10 +967,10 @@&lt;br /&gt;
      }&lt;br /&gt;
  &lt;br /&gt;
      if ( lc( $args{&amp;#039;ENTRYAGGREGATOR&amp;#039;} || &amp;quot;&amp;quot; ) eq &amp;#039;none&amp;#039; || !@$restriction ) {&lt;br /&gt;
 -        @$restriction = (@prefix, $clause);&lt;br /&gt;
 +        @$restriction = (@prefix, @clause);&lt;br /&gt;
      }&lt;br /&gt;
      else {&lt;br /&gt;
 -        push @$restriction, $args{&amp;#039;ENTRYAGGREGATOR&amp;#039;}, @prefix, $clause;&lt;br /&gt;
 +        push @$restriction, $args{&amp;#039;ENTRYAGGREGATOR&amp;#039;}, @prefix, @clause;&lt;br /&gt;
      }&lt;br /&gt;
  &lt;br /&gt;
      return ( $args{&amp;#039;ALIAS&amp;#039;} );&lt;br /&gt;
&lt;br /&gt;
* To prepare already converted [[PostgreSQL]] database run:&lt;br /&gt;
&lt;br /&gt;
 rt-mysql2pg -v --dst-dsn dbi:Pg:dbname=rt3 --fulltext --vacuum&lt;br /&gt;
&lt;br /&gt;
-- zito&lt;/div&gt;</summary>
		<author><name>95.173.94.255</name></author>
	</entry>
</feed>