7

I created a fuzzy search in C# for a PostgreSQL database using the similarity() function from the pg_trgm module. Now I want to port this search to a MySQL database, but MySQL has no similar trigram functionality.

Is there a way to import the pg-trgm module from PostgreSQL in MySQL or is there a similar implementation of Trigrams for MySQL?

Unfortunately I was not able to find any satisfying implementation yet.

I am reluctant to use a external search engine like Solr due to the effort of installation, maintenance and becoming acquainted with the syntax and configuration.

Chris Travers
  • 25,424
  • 6
  • 65
  • 182
ischas
  • 169
  • 2
  • 12
  • Perhaps this will help you? http://stackoverflow.com/questions/3320698/what-is-the-best-way-to-implement-a-substring-search-in-sql – Benvorth Aug 08 '13 at 10:32

2 Answers2

2

I know this question is old, but I got here Google searching for this and there is a bit of new information I also found.

As of Mysql 5.7.6, there is built in support for using nGram in full text searches.

Mysql team article regarding ngram searches

Reid Johnson
  • 1,394
  • 14
  • 20
0

I am not familiar with PostgreSQL but if you are using Innodb storage engine then make the column in which you are tring to search "Full-Text" search. then you can use the following search syntax to search your contant

SELECT subject, MATCH (subject) AGAINST ("Find This String") AS relevance_notes
FROM yourTable

http://dev.mysql.com/doc/refman/5.5/en/fulltext-search.html#function_match

Jaylen
  • 39,043
  • 40
  • 128
  • 221