postgresqlfull-text-searchfuzzy-searchtrigrammisspelling

fuzzy search in full text search


I'm using postgresql to Full Text Search and I am finding that users will not receive results if there are misspellings.I want to use fuzzy search and full text search together.For example I could not combine Trigram indexes and full text search.

What is the best way to handle misspelt words in Postgres full text search?


Solution

  • I'd suggest that you either use full-text search or trigram similarity matching, but don't try to mix them.

    Based on the requirement, I would say that trigram similarity matching is the better fit.

    If you don't get a result using the similarity operator %, you have two choices:

    1. Lower the similarity threshold pg_trgm.similarity_threshold.

    2. Query in a different way so that you get the best matches, however „distant” they are:

      SELECT * FROM product ORDER BY katadi <-> ' pen' LIMIT 10;
      

      I think that would be the better solution.