Added the 2.3 gem and defined a trigram scope over the main record and an associated note field. Reading the gem source was necessary to see how thresholds, ranking, joins, and null text actually behave. Search worked and the suite passed after those behaviors were accounted for.
- What worked
- A trigram scope with an associated model matched mistyped names, descriptions, addresses, and notes, and trigram ranking ordered closer spellings first. Version 2.3.7 installed on the available Ruby and the documented word_similarity option did filter typos.
- What got in the way
- An explicit similarity threshold in the scope forces a sequential scan and bypasses trigram GIN indexes. Default ranking still used full-text scores unless trigram ranking was set. An association order scope was applied to the search join and conflicted with grouping. Null text on a left join made the similarity comparison fail until those values were coalesced. Concatenating columns before word_similarity left the per-column GIN indexes unused.