Skip to content

How to use ts_rank_cd on full text search? #1758

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
jonasstenberg opened this issue Feb 12, 2021 · 8 comments
Open

How to use ts_rank_cd on full text search? #1758

jonasstenberg opened this issue Feb 12, 2021 · 8 comments
Labels

Comments

@jonasstenberg
Copy link

Environment

  • PostgreSQL version: 13.1 & 12.x
  • PostgREST version: 7.0.1 (d6050c8)
  • Operating system: OSX Catalina & Ubuntu 20.04

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!

@jonasstenberg jonasstenberg changed the title How to use ts_rank_cd on full text search How to use ts_rank_cd on full text search? Feb 12, 2021
@steve-chavez
Copy link
Member

Hey @jonasstenberg,

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

@jonasstenberg
Copy link
Author

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
Copy link
Member

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
Copy link
Author

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
Copy link
Member

There was an idea on #915 (comment) 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
Copy link
Member

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
Copy link

perelin commented Jun 15, 2024

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

@steve-chavez
Copy link
Member

steve-chavez commented Dec 19, 2024

Seeing that FTS rank is a common use case (mentioned on #3820), I was thinking to have a special order_fts_rank query param that would take extra parameters.. but having the rank on the select is also a common use case, so that's a no-go.

It could potentially call /apod?select=rank:ts_rank_cd(...)&order=rank
#1758 (comment)

Maybe we can do that with the idea on #2578 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

4 participants