jirutka/rsql-parser

Is it possible to filter by the json fields?

AdrianC2000 opened this issue · 4 comments

I would like to achieve something like this:
select * from events where params->>'name' = 'name123';
Params is the column of json type and has in it the field 'name'.
So the goal is to filter by the fields that are present in the json.
Is it possible with the usage of rsql parser?

It depends on how you structure your data inside Java and how you implement parsing the attribute.

arvit1 commented

Hello all
do you have an example on how to structure the data in order to have rsql work on json column

So we have any update on this or idea on how we implement this feature

One approach that I used in a project is to define a custom operator:

  • Having key : =k=key
  • Having key with value =kv=(key, value)

Then JPA + PostgreSQL requires some customization so that JPA "knows" the specific syntax of Postgres. Another way is to use MongoDB which has more support for the dot annotation.