right now with Postgres and pg_tgrm if I do any similarity(strict word, word, or just standard) it does it based on words so the query 'ruined by' will get a rank of 1 for the term 'ruined' but less for something like 'ruined by design' is there a way to do it on whole phrases. I tried using FTS but that has the problem where 'ruined by' won't match 'ruined' at all unless you use 'ruined | by' but using | makes order no longer matter is this something that is possible at all. thanks
Asked
Active
Viewed 121 times
1 Answers
0
Similarity search is always a heuristics; I don't think that there is a way to automatically “do the right thing”.
If I read your question right, and you also want to find matches for the components of a phrase, perhaps you should use full text search an preprocess the search term to indicate explicitly what you want.
Then ruined by
would become
to_tsquery('ruined | by | ruined <-> by')

Laurenz Albe
- 209,280
- 17
- 206
- 263
-
that's helpful as a heuristic is there any way to add more weight to the 'ruined <-> by' part – Quinn Pollock May 15 '20 at 05:26
-
I don't think so. You would have to run two searches, one for the phrase and another for the parts. – Laurenz Albe May 15 '20 at 05:35