<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Full Text Search &#8211; Database Research &amp; Development</title>
	<atom:link href="https://www.dbrnd.com/tag/full-text-search/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.dbrnd.com</link>
	<description>BIGData &#124; NoSQL &#124; MSSQL &#124; MySQL &#124; PostgreSQL</description>
	<lastBuildDate>Mon, 24 Jun 2019 19:41:46 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0.6</generator>
	<item>
		<title>PostgreSQL: Create Index on Full Text Search tsvector Data</title>
		<link>https://www.dbrnd.com/2019/07/postgresql-create-index-on-full-text-search-tsvector-data/</link>
					<comments>https://www.dbrnd.com/2019/07/postgresql-create-index-on-full-text-search-tsvector-data/#respond</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Mon, 22 Jul 2019 16:16:31 +0000</pubDate>
				<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[Full Text Search]]></category>
		<category><![CDATA[plpgsql]]></category>
		<category><![CDATA[Postgres Query]]></category>
		<category><![CDATA[postgresql]]></category>
		<category><![CDATA[PostgreSQL Administrator]]></category>
		<category><![CDATA[PostgreSQL Error]]></category>
		<category><![CDATA[PostgreSQL Monitoring]]></category>
		<category><![CDATA[PostgreSQL Performance Tuning]]></category>
		<category><![CDATA[PostgreSQL Programming]]></category>
		<category><![CDATA[PostgreSQL Tips and Tricks]]></category>
		<category><![CDATA[to_tsquery]]></category>
		<category><![CDATA[tsvector]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=6968</guid>

					<description><![CDATA[In this post, I am sharing an example of applying Full Text Search on PostgreSQL Table with Index. Here, I am using tsvector for full text search which is document type and uses match operator like @@. PostgreSQL: Example of Trigram Index for Full Text Search using pg_trgm Extension Below is an example: Create a [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2019%2F07%2Fpostgresql-create-index-on-full-text-search-tsvector-data%2F&amp;linkname=PostgreSQL%3A%20Create%20Index%20on%20Full%20Text%20Search%20tsvector%20Data" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2019%2F07%2Fpostgresql-create-index-on-full-text-search-tsvector-data%2F&amp;linkname=PostgreSQL%3A%20Create%20Index%20on%20Full%20Text%20Search%20tsvector%20Data" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2019%2F07%2Fpostgresql-create-index-on-full-text-search-tsvector-data%2F&amp;linkname=PostgreSQL%3A%20Create%20Index%20on%20Full%20Text%20Search%20tsvector%20Data" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2019%2F07%2Fpostgresql-create-index-on-full-text-search-tsvector-data%2F&amp;linkname=PostgreSQL%3A%20Create%20Index%20on%20Full%20Text%20Search%20tsvector%20Data" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2019%2F07%2Fpostgresql-create-index-on-full-text-search-tsvector-data%2F&amp;linkname=PostgreSQL%3A%20Create%20Index%20on%20Full%20Text%20Search%20tsvector%20Data" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2019%2F07%2Fpostgresql-create-index-on-full-text-search-tsvector-data%2F&amp;linkname=PostgreSQL%3A%20Create%20Index%20on%20Full%20Text%20Search%20tsvector%20Data" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2019%2F07%2Fpostgresql-create-index-on-full-text-search-tsvector-data%2F&#038;title=PostgreSQL%3A%20Create%20Index%20on%20Full%20Text%20Search%20tsvector%20Data" data-a2a-url="https://www.dbrnd.com/2019/07/postgresql-create-index-on-full-text-search-tsvector-data/" data-a2a-title="PostgreSQL: Create Index on Full Text Search tsvector Data"></a></p><p>In this post, I am sharing an example of applying Full Text Search on PostgreSQL Table with Index. </p>
<p>Here, I am using tsvector for full text search which is document type and uses match operator like @@.</p>
<blockquote class="wp-embedded-content" data-secret="FxWul5DgOM"><p><a href="https://www.dbrnd.com/2016/08/postgresql-example-of-trigram-index-for-full-text-search-using-pg_trgm-extension/">PostgreSQL: Example of Trigram Index for Full Text Search using pg_trgm Extension</a></p></blockquote>
<p><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2016/08/postgresql-example-of-trigram-index-for-full-text-search-using-pg_trgm-extension/embed/#?secret=FxWul5DgOM" data-secret="FxWul5DgOM" width="600" height="338" title="&#8220;PostgreSQL: Example of Trigram Index for Full Text Search using pg_trgm Extension&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<p><strong>Below is an example:</strong></p>
<p><strong>Create a sample table with data:</strong></p>
<pre class="crayon-plain-tag">CREATE TABLE tbl_Textdata
(id int, txt character varying);

INSERT INTO tbl_Textdata VALUES
(1,'I am DBA'),(2,'database research &amp; development'),(3,'think for data only')
,(4,'data is important'),(5,'data is a future'),(6,'I am data owner');</pre> </p>
<p><strong>Do Full Text Searching:</strong></p>
<pre class="crayon-plain-tag">SELECT txt
FROM tbl_Textdata
WHERE to_tsvector(txt) @@ to_tsquery('data');</pre> </p>
<p><strong>Result:</strong></p>
<pre class="crayon-plain-tag">txt
--------------------------
'think for data only'
'data is important'
'data is a future'
'I am data owner'</pre> </p>
<p><strong>Apply an Index on require Text Pattern:</strong></p>
<pre class="crayon-plain-tag">CREATE INDEX tbl_Textdata_txt_idx ON tbl_Textdata USING GIN (to_tsvector('english',txt));</pre> </p>
<p><strong>Check the execution plan:</strong></p>
<pre class="crayon-plain-tag">explain analyze
SELECT txt
FROM tbl_Textdata
WHERE to_tsvector(txt) @@ to_tsquery('data');

'Seq Scan on tbl_textdata  (cost=0.00..4.07 rows=1 width=32) (actual time=0.043..0.058 rows=4 loops=1)'
'  Filter: (to_tsvector((txt)::text) @@ to_tsquery('data'::text))'
'  Rows Removed by Filter: 2'
'Planning time: 5.494 ms'
'Execution time: 0.083 ms'</pre> </p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2019/07/postgresql-create-index-on-full-text-search-tsvector-data/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>PostgreSQL: Full Text Search using tsvector</title>
		<link>https://www.dbrnd.com/2018/03/postgresql-full-text-search-using-tsvector/</link>
					<comments>https://www.dbrnd.com/2018/03/postgresql-full-text-search-using-tsvector/#comments</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Sat, 31 Mar 2018 16:16:22 +0000</pubDate>
				<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[Full Text Search]]></category>
		<category><![CDATA[plpgsql]]></category>
		<category><![CDATA[Postgres Query]]></category>
		<category><![CDATA[postgresql]]></category>
		<category><![CDATA[PostgreSQL Administrator]]></category>
		<category><![CDATA[PostgreSQL Error]]></category>
		<category><![CDATA[PostgreSQL Monitoring]]></category>
		<category><![CDATA[PostgreSQL Performance Tuning]]></category>
		<category><![CDATA[PostgreSQL Programming]]></category>
		<category><![CDATA[PostgreSQL Tips and Tricks]]></category>
		<category><![CDATA[to_tsquery]]></category>
		<category><![CDATA[tsquery]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=6962</guid>

					<description><![CDATA[In this post, I am sharing few examples of full text searching and pattern matching in PostgreSQL. PostgreSQL provides the different options for Full text searching and pattern matching. Here, I am using tsvector for full text search which is document type and uses match operator like @@. PostgreSQL: Example of Trigram Index for Full [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F03%2Fpostgresql-full-text-search-using-tsvector%2F&amp;linkname=PostgreSQL%3A%20Full%20Text%20Search%20using%20tsvector" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F03%2Fpostgresql-full-text-search-using-tsvector%2F&amp;linkname=PostgreSQL%3A%20Full%20Text%20Search%20using%20tsvector" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F03%2Fpostgresql-full-text-search-using-tsvector%2F&amp;linkname=PostgreSQL%3A%20Full%20Text%20Search%20using%20tsvector" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F03%2Fpostgresql-full-text-search-using-tsvector%2F&amp;linkname=PostgreSQL%3A%20Full%20Text%20Search%20using%20tsvector" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F03%2Fpostgresql-full-text-search-using-tsvector%2F&amp;linkname=PostgreSQL%3A%20Full%20Text%20Search%20using%20tsvector" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F03%2Fpostgresql-full-text-search-using-tsvector%2F&amp;linkname=PostgreSQL%3A%20Full%20Text%20Search%20using%20tsvector" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F03%2Fpostgresql-full-text-search-using-tsvector%2F&#038;title=PostgreSQL%3A%20Full%20Text%20Search%20using%20tsvector" data-a2a-url="https://www.dbrnd.com/2018/03/postgresql-full-text-search-using-tsvector/" data-a2a-title="PostgreSQL: Full Text Search using tsvector"></a></p><p>In this post, I am sharing few examples of full text searching and pattern matching in PostgreSQL.<br />
PostgreSQL provides the different options for Full text searching and pattern matching. </p>
<p>Here, I am using tsvector for full text search which is document type and uses match operator like @@.</p>
<blockquote class="wp-embedded-content" data-secret="NNhHDXlpwL"><p><a href="https://www.dbrnd.com/2016/08/postgresql-example-of-trigram-index-for-full-text-search-using-pg_trgm-extension/">PostgreSQL: Example of Trigram Index for Full Text Search using pg_trgm Extension</a></p></blockquote>
<p><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2016/08/postgresql-example-of-trigram-index-for-full-text-search-using-pg_trgm-extension/embed/#?secret=NNhHDXlpwL" data-secret="NNhHDXlpwL" width="600" height="338" title="&#8220;PostgreSQL: Example of Trigram Index for Full Text Search using pg_trgm Extension&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<p><strong>Below are the few examples of Full Text Search:</strong></p>
<p><strong>Casting in tsvector:</strong></p>
<pre class="crayon-plain-tag">SELECT 'I am owner of dbrnd.com'::tsvector @@ 'am &amp; of'::tsquery as Result

result 
---------
true


SELECT 'I am owner of dbrnd.com'::tsvector @@ 'am & dbrnd.com'::tsquery as Result

result 
---------
true

SELECT 'I am owner of dbrnd.com'::tsvector @@ 'am & dbrnd'::tsquery as Result

result 
---------
false</pre> </p>
<p><strong>Use to_tsvector():</strong></p>
<pre class="crayon-plain-tag">SELECT to_tsvector('I am owner of dbrnd.com') @@ to_tsquery('owner &amp; dbrnd.com') as Result

result 
---------
true</pre> </p>
<p><strong>Search adjacent string combination:</strong></p>
<pre class="crayon-plain-tag">SELECT to_tsvector('anvesh patel') @@ to_tsquery('anvesh &lt;-&gt; patel') as Result

result 
---------
true

SELECT to_tsvector('anvesh m patel') @@ to_tsquery('anvesh &lt;-&gt; patel') as Result

result 
---------
false

SELECT to_tsvector('anvesh m patel') @@ to_tsquery('anvesh &lt;2&gt; patel') as Result

result 
---------
true</pre> </p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2018/03/postgresql-full-text-search-using-tsvector/feed/</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
			</item>
		<item>
		<title>SQL Server: Create Full Text Search Index, Use CONTAINS for pattern matching</title>
		<link>https://www.dbrnd.com/2018/03/sql-server-create-full-text-search-index-use-contains-for-pattern-matching/</link>
					<comments>https://www.dbrnd.com/2018/03/sql-server-create-full-text-search-index-use-contains-for-pattern-matching/#comments</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Sat, 03 Mar 2018 16:16:26 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[contains]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[Full Text Search]]></category>
		<category><![CDATA[Pattern Matching]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Server Administrator]]></category>
		<category><![CDATA[SQL Server Error]]></category>
		<category><![CDATA[SQL Server Monitoring]]></category>
		<category><![CDATA[SQL Server Performance Tuning]]></category>
		<category><![CDATA[SQL Server Programming]]></category>
		<category><![CDATA[SQL Server Tips and Tricks]]></category>
		<category><![CDATA[TSQL]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=7176</guid>

					<description><![CDATA[In this post, I am sharing the use of CONTAINS for matching the patterns in SQL Server. We know about the LIKE predicate which we are using for a specific type of pattern matching. SQL Server Full-Text Search Index stores the different patterns of the defined column. We can employ CONTAINS on the column of [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F03%2Fsql-server-create-full-text-search-index-use-contains-for-pattern-matching%2F&amp;linkname=SQL%20Server%3A%20Create%20Full%20Text%20Search%20Index%2C%20Use%20CONTAINS%20for%20pattern%20matching" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F03%2Fsql-server-create-full-text-search-index-use-contains-for-pattern-matching%2F&amp;linkname=SQL%20Server%3A%20Create%20Full%20Text%20Search%20Index%2C%20Use%20CONTAINS%20for%20pattern%20matching" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F03%2Fsql-server-create-full-text-search-index-use-contains-for-pattern-matching%2F&amp;linkname=SQL%20Server%3A%20Create%20Full%20Text%20Search%20Index%2C%20Use%20CONTAINS%20for%20pattern%20matching" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F03%2Fsql-server-create-full-text-search-index-use-contains-for-pattern-matching%2F&amp;linkname=SQL%20Server%3A%20Create%20Full%20Text%20Search%20Index%2C%20Use%20CONTAINS%20for%20pattern%20matching" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F03%2Fsql-server-create-full-text-search-index-use-contains-for-pattern-matching%2F&amp;linkname=SQL%20Server%3A%20Create%20Full%20Text%20Search%20Index%2C%20Use%20CONTAINS%20for%20pattern%20matching" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F03%2Fsql-server-create-full-text-search-index-use-contains-for-pattern-matching%2F&amp;linkname=SQL%20Server%3A%20Create%20Full%20Text%20Search%20Index%2C%20Use%20CONTAINS%20for%20pattern%20matching" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F03%2Fsql-server-create-full-text-search-index-use-contains-for-pattern-matching%2F&#038;title=SQL%20Server%3A%20Create%20Full%20Text%20Search%20Index%2C%20Use%20CONTAINS%20for%20pattern%20matching" data-a2a-url="https://www.dbrnd.com/2018/03/sql-server-create-full-text-search-index-use-contains-for-pattern-matching/" data-a2a-title="SQL Server: Create Full Text Search Index, Use CONTAINS for pattern matching"></a></p><p>In this post, I am sharing the use of CONTAINS for matching the patterns in SQL Server. </p>
<p>We know about the LIKE predicate which we are using for a specific type of pattern matching. SQL Server Full-Text Search Index stores the different patterns of the defined column. </p>
<p>We can employ CONTAINS on the column of Full-Text Search and can search different patterns. </p>
<p><strong>Please check the below demonstrations:</strong></p>
<p><strong>Create a table with sample records:</strong></p>
<pre class="crayon-plain-tag">CREATE TABLE tbl_Employee (empid int not null, ename varchar(20) not null, salary int)
GO

INSERT INTO tbl_Employee VALUES 
(1,'abc',25000),(2,'xyz',30000),(3,'svq',40000)
,(4,'cvq',26000),(5,'rfq',70000),(6,'opq',45000)
GO</pre> </p>
<p><strong>Create a Full Text Search Index:</strong></p>
<pre class="crayon-plain-tag">CREATE UNIQUE INDEX uk_empid ON tbl_Employee(empid);
  
CREATE FULLTEXT CATALOG ft AS DEFAULT; 

CREATE FULLTEXT INDEX ON tbl_Employee(ename)   
   KEY INDEX uk_empid   
   WITH STOPLIST = SYSTEM;</pre> </p>
<p><strong>Use CONTAINS, for performing FULL Text Search:</strong><br />
Check the below sample use of CONTAINS, If you want to use the same thing using LIKE then we have to write LIKE separately for each pattern. </p>
<pre class="crayon-plain-tag">SELECT *FROM [dbo].[tbl_Employee]
WHERE CONTAINS(ename, '"a*" OR "s*" OR "cv*"')</pre> </p>
<p><strong>Result:</strong></p>
<pre class="crayon-plain-tag">empid       ename                salary
----------- -------------------- -----------
1           abc                  25000
3           svq                  40000
4           cvq                  26000</pre> </p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2018/03/sql-server-create-full-text-search-index-use-contains-for-pattern-matching/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>PostgreSQL: Example of Trigram Index for Full Text Search using pg_trgm Extension</title>
		<link>https://www.dbrnd.com/2016/08/postgresql-example-of-trigram-index-for-full-text-search-using-pg_trgm-extension/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Tue, 23 Aug 2016 17:51:41 +0000</pubDate>
				<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[Full Text Search]]></category>
		<category><![CDATA[pg_trgm]]></category>
		<category><![CDATA[plpgsql]]></category>
		<category><![CDATA[Postgres Query]]></category>
		<category><![CDATA[postgresql]]></category>
		<category><![CDATA[PostgreSQL Administrator]]></category>
		<category><![CDATA[PostgreSQL Error]]></category>
		<category><![CDATA[PostgreSQL Programming]]></category>
		<category><![CDATA[PostgreSQL Tips and Tricks]]></category>
		<category><![CDATA[Trigram Index]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=3551</guid>

					<description><![CDATA[In the PostgreSQL, we can use Trigram to enhance the use of Full Text Search. The Trigram algorithm divides string like &#8220;dog&#8221; = &#8220;d&#8221;,&#8221;do&#8221;,&#8221;dog&#8221;,&#8221;og&#8221;. The Trigram matching comes with pg_trgm extension. We can also apply Trigram operators on Gist and GIN indexes which increase the search speed and enhance the performance. We have already different [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F08%2Fpostgresql-example-of-trigram-index-for-full-text-search-using-pg_trgm-extension%2F&amp;linkname=PostgreSQL%3A%20Example%20of%20Trigram%20Index%20for%20Full%20Text%20Search%20using%20pg_trgm%20Extension" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F08%2Fpostgresql-example-of-trigram-index-for-full-text-search-using-pg_trgm-extension%2F&amp;linkname=PostgreSQL%3A%20Example%20of%20Trigram%20Index%20for%20Full%20Text%20Search%20using%20pg_trgm%20Extension" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F08%2Fpostgresql-example-of-trigram-index-for-full-text-search-using-pg_trgm-extension%2F&amp;linkname=PostgreSQL%3A%20Example%20of%20Trigram%20Index%20for%20Full%20Text%20Search%20using%20pg_trgm%20Extension" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F08%2Fpostgresql-example-of-trigram-index-for-full-text-search-using-pg_trgm-extension%2F&amp;linkname=PostgreSQL%3A%20Example%20of%20Trigram%20Index%20for%20Full%20Text%20Search%20using%20pg_trgm%20Extension" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F08%2Fpostgresql-example-of-trigram-index-for-full-text-search-using-pg_trgm-extension%2F&amp;linkname=PostgreSQL%3A%20Example%20of%20Trigram%20Index%20for%20Full%20Text%20Search%20using%20pg_trgm%20Extension" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F08%2Fpostgresql-example-of-trigram-index-for-full-text-search-using-pg_trgm-extension%2F&amp;linkname=PostgreSQL%3A%20Example%20of%20Trigram%20Index%20for%20Full%20Text%20Search%20using%20pg_trgm%20Extension" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F08%2Fpostgresql-example-of-trigram-index-for-full-text-search-using-pg_trgm-extension%2F&#038;title=PostgreSQL%3A%20Example%20of%20Trigram%20Index%20for%20Full%20Text%20Search%20using%20pg_trgm%20Extension" data-a2a-url="https://www.dbrnd.com/2016/08/postgresql-example-of-trigram-index-for-full-text-search-using-pg_trgm-extension/" data-a2a-title="PostgreSQL: Example of Trigram Index for Full Text Search using pg_trgm Extension"></a></p><p>In the PostgreSQL, we can use Trigram to enhance the use of Full Text Search.<br />
The Trigram algorithm divides string like &#8220;dog&#8221; = &#8220;d&#8221;,&#8221;do&#8221;,&#8221;dog&#8221;,&#8221;og&#8221;.</p>
<blockquote><p>The Trigram matching comes with pg_trgm extension.<br />
We can also apply Trigram operators on Gist and GIN indexes which increase the search speed and enhance the performance. </p></blockquote>
<p>We have already different thesaurus or synomyms for the Full Text Search, but we can use Trigram for implementing typing corrections and suggestions. </p>
<p>Here, you can find different examples of this. </p>
<p><strong>Create a sample table:</strong></p>
<pre class="crayon-plain-tag">CREATE TABLE tbl_TestTriGramIndex
(
	ID INT
	,TextData TEXT
);</pre> </p>
<p><strong>Create a Trigram Index on Text Column:</strong></p>
<pre class="crayon-plain-tag">CREATE INDEX trgm_idx_tbl_TestTriGramIndex_TextData ON tbl_TestTriGramIndex USING GIST (TextData gist_trgm_ops);</pre> </p>
<p><strong>If you get below error, install require pg_trgm extension:</strong></p>
<pre class="crayon-plain-tag">ERROR:  operator class "gist_trgm_ops" does not exist for access method "gist"</pre> </p>
<p><strong>Install pg_trgm extension:</strong></p>
<pre class="crayon-plain-tag">CREATE EXTENSION pg_trgm;</pre> </p>
<p><strong>Insert few sample records:</strong></p>
<pre class="crayon-plain-tag">INSERT INTO tbl_TestTriGramIndex
VALUES 
(1,'Anvesh Patel')
,(2,'Database Research &amp; Development')
,(3,'PostgreSQL is better than SQL Server')
,(4,'PostgreSQL is supported powerful BRIN Indexes');</pre> </p>
<p><strong>Execute few SELECTs for text comparison:</strong></p>
<pre class="crayon-plain-tag">SELECT *FROM tbl_TestTriGramIndex
WHERE TextData % 'PostgreSQL is';

SELECT *FROM tbl_TestTriGramIndex
WHERE TextData LIKE '%SQL%';

SELECT *FROM tbl_TestTriGramIndex
WHERE TextData ~* 'ql';</pre> </p>
<p><strong>Execute below SELECTs and check Trigram generated result of given string:</strong></p>
<pre class="crayon-plain-tag">SELECT SHOW_TRGM('Anvesh') AS Anvesh;
SELECT SHOW_TRGM('Anvesh Patel') AS AnveshPatel;</pre> </p>
<p><strong>Execute below SELECTs and check percentage of similarity:</strong></p>
<pre class="crayon-plain-tag">SELECT SIMILARITY('Anvesh','anv') AS SimilarPercentage;
SELECT SIMILARITY('Anvesh','anve') AS SimilarPercentage;</pre> </p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
