Thanks for your replies. Sorry for confusion. Instead of `similarity(lhs, rhs) >= show_limit()`, which of course is completely equivalent to `lhs % rhs`, I wanted to write `similarity(lhs, rhs) >= my_custom_threshold`. It seems that the approach with ternary operators is quite a bit of work. I might have a simpler idea:
pg_trgm also provides `<->` but it seems this operator doesn't use indexes either. It seems the shortest path to per-query thresholds, without compromising the design, is making this operator use the index. Please help me understand whether my reasoning is correct. If it is, I'd appreciate a high-level overview of what needs to be done. I can block a few hours to work on this in the upcoming weeks. Best regards -- Greg Navis I help tech companies to scale Heroku-hosted Rails apps. Free, biweekly scalability newsletter for SaaS CEOs <http://www.gregnavis.com/newsletter/>