I tried using pg_search Trigram search with word_similarity. As per the documentation on github it says that Trigram search requires the trigram extension.
But, what I have done to fix this error is by running CREATE EXTENSION pg_trgm; in psql and the return message was 'extension "pg_trgm" already exists'. That means the trigram extension should have been added to my postgres.
However, the error appears with the settings below:
include PgSearch::Model
pg_search_scope :search_suggestion,
against: %i[title],
associated_against: { owner: %i[name legal_name] },
using: { tsearch: { dictionary: 'english' }, trigram: { word_similarity: true } },
ranked_by: ":trigram"
Error message:
PG::UndefinedFunction: ERROR: function word_similarity(unknown, text) does not exist LINE 1:
...NER JOIN (SELECT "table"."title" AS pg_search_id, (word_simil...
^ HINT: No function matches the given name and argument types. You might need to add explicit type casts.
I'm using string as the attribute data type.