postgraphile-plugin-connection-filter icon indicating copy to clipboard operation
postgraphile-plugin-connection-filter copied to clipboard

Support of pg_trgm with ranking

Open auwtch opened this issue 5 years ago • 4 comments

Currently I have the query

create index on pub.product using gin (title gin_trgm_ops);

select title 
  from pub.product 
 where title %> 'search phrase' 
 order by title <->> 'search phrase';

I will be grateful for adding this functionality to the library, or instructions on how to write this plugin yourself.

auwtch avatar Jul 22 '20 16:07 auwtch

I'm not familiar with pg_trgm, but it should definitely be doable. As a starting point, consider looking at https://github.com/graphile-contrib/postgraphile-plugin-connection-filter-postgis which extends this plugin with PostGIS-specific operators.

mattbretl avatar Aug 02 '21 01:08 mattbretl

Caveat: if you need ORDER BY, there'll be more work involved. This plugin is only concerned with augmenting the WHERE clause.

mattbretl avatar Aug 02 '21 01:08 mattbretl

I'm interested, too. Do you have some code example for fetching all text/varchar columns, that are covered by an index using gist or gin?

TimoStolz avatar Apr 12 '22 10:04 TimoStolz

Probably the fulltext plugin could be a related use case: https://github.com/mlipscombe/postgraphile-plugin-fulltext-filter

TimoStolz avatar Apr 12 '22 10:04 TimoStolz