PostgREST / postgrest

REST API for any Postgres database
https://postgrest.org
MIT License
22.65k stars 1k forks source link

How to use ts_rank_cd on full text search? #1758

Open jonasstenberg opened 3 years ago

jonasstenberg commented 3 years ago

Environment

Description of issue

When using full text search that's documented here: https://postgrest.org/en/stable/api.html?highlight=order#full-text-search, how do you use ts_rank_cd (https://www.postgresql.org/docs/13/textsearch-controls.html#TEXTSEARCH-RANKING) to rank the results? If you provide me with a good example I can perhaps put together a PR with documentation for it.

Thanks!

steve-chavez commented 3 years ago

Hey @jonasstenberg,

You'll need to create a stored procedure for that: https://postgrest.org/en/stable/api.html#stored-procedures

jonasstenberg commented 3 years ago

Alright, thanks!

Don't know Haskell myself but is this a feature planned to be included or is it meant to be implemented in an RPC in the future too?

wolfgangwalther commented 3 years ago

Don't know Haskell myself but is this a feature planned to be included or is it meant to be implemented in an RPC in the future too?

At this point this is more of a "how would we even do this?" question. Afaik, there hasn't been a suggestion how this could be included in the regular query syntax, yet. I'm failing to come up with something on the spot.

jonasstenberg commented 3 years ago

Ok, I understand. I don't really know how such a query syntax would look either so I guess I'd have to settle with the rpc option for now.

Many thanks for the answers though!

steve-chavez commented 3 years ago

There was an idea on https://github.com/PostgREST/postgrest/issues/915#issuecomment-776060792 for calling functions on the url.

It could potentially call /apod?select=rank:ts_rank_cd(...)&order=rank, but that will take a while to get implemented. So RPC is definitely the way to go for now.

wolfgangwalther commented 3 years ago

There was an idea on #915 (comment) for calling functions on the url.

I understood this as only taking column names as function arguments...

It could potentially call /apod?select=rank:ts_rank_cd(...)&order=rank, but that will take a while to get implemented.

... and I think ts_rank_cd needs user input. And then we'd need to be able to use aliased expressions by alias in the order param, too. I don't think that's straightforward, either.

So "a while" is a very nice way to put it ;).

perelin commented 1 week ago

Just hit this wall as well. Any chances of this getting put on the roadmap?