Using tsvector operators #7505
-
Hi, I am trying to learn how to use tsvector operators in a graphql query, but not able to find documentation about it. Here's the corresponding sql query I am trying to run. select * from table where text_search_vector @@ plainto_tsquery('search_string') Is this doable with Hasura operators? Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
here is a list of supported postgres operators and their equivalent in graphql. |
Beta Was this translation helpful? Give feedback.
-
Thanks for you response Benoit. I looked into custom defined functions option - but it only solves the most basic use cases. Based on playing around with it, I am only able to send text arguments to the custom function and the graphql api does not interpret a boolean tsquery. To get this to work on a general query would require a lot of string wrangling to get the query into a shape that would work. I think if the RFC is implemented, it would certainly help for these use cases. |
Beta Was this translation helpful? Give feedback.
-
Got it, thanks Benoit. In that case, in the absence of first class support for text search operators https://www.postgresql.org/docs/10/functions-textsearch.html in the query language, doing non-trivial search over the graphql api becomes really hard. E.g. a interpreting a boolean expression with multiple clauses in the custom function, "term1" && ("term2" || "term3") |
Beta Was this translation helpful? Give feedback.
here is a list of supported postgres operators and their equivalent in graphql.
There is no currently available way to use tsvector with the api automatically provided by hasura.
This leaves you with a few options, the simplest of which is most likely table computed fields.
There is an open RFC for parametrized queries which will offer a more ergonomic solution in the future.
You can find it here