Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using Trigram pg extension for more performant text similarity searches #1466

Open
maindsh opened this issue Dec 8, 2023 · 0 comments
Open

Comments

@maindsh
Copy link

maindsh commented Dec 8, 2023

It is a known fact that using LIKE and ILIKE queries all of rows are scanned in the table. Compared to using Trigram (pg extension) instead of sequentially scanning all of the rows in the document, only the gin index is scanned which is at least 100X faster.

https://mazeez.dev/posts/pg-trgm-similarity-search-and-fast-like

Related to this is Ransack *_matches (and others) which internally uses these LIKE queries https://activerecord-hackery.github.io/ransack/getting-started/search-matches/

So my question is, is there a way to override the Ransack matchers to use Similarity function similarity('your-search-term') instead of LIKE ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant