graphile-contrib / postgraphile-plugin-connection-filter

Filtering on PostGraphile connections
MIT License
283 stars 32 forks source link

Support of pg_trgm with ranking #132

Open blasterpistol opened 4 years ago

blasterpistol commented 4 years ago

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.

mattbretl commented 3 years ago

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 commented 3 years ago

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

TimoStolz commented 2 years ago

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 commented 2 years ago

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