spring rest multiple filter

1.3k views Asked by At

i have an entity for i.e stock table ( attribute item, quantity, weight, expiration date .. ecc)... how can do a dynamic query on my rest spring backend ? For i.e the user can do a query without filter but can also do a query with multiple filter for i,e quantity>0 and item = x and expiration data > yesterday... so i have to develop the parse to accept not a fixed number of parameters. My second question is that my rest api must accept = as operator but also < > >= <= != to do filter query. Thanks

1

There are 1 answers

2
Chirdeep Tomar On BEST ANSWER

I am not sure if spring provides any such functionality. You will have to take the conditions for your filters in a map, build an expression parser and then build queries at run time.

I would say a better solution is to look at graphql.

http://graphql.org/

Spring has support for GraphQL https://github.com/oembedler/graphql-spring-boot