jirutka/rsql-parser

How to add orderBy

Closed this issue · 4 comments

Is it possible to add orderBy as an operator or how should it be done.

It should be something along the lines of:

  1. Implement a new Node, e.g. OrderByNode
  2. Modify the grammar (src/main/javacc/RSQLParser.jj) by:
    • adding a new TOKEN, e.g. orderBy
    • defining the OrderBy rule
    • extending the Input rule (by adding the OrderBy rule to it).
  3. Add a new method to the RSQLVisitor interface to handle the new node.

I recommend to use separate URI query parameter for sorting, e.g. ?query=name==Flynn&sortBy=name, not to mix it with RSQL expression. The same applies to paging; I recommend URI parameters named limit and offset.

Hi Jirutka

How to sort the result set of a rest service response, if we are supporting pagination. the solution to use of a separate query parameter "e.g. ?query=name==Flynn&sortBy=name" will works without pagination. but if we have implemented pagination in our service, in which we need to add order by clause for the RSQL Query , then how to implement sorting on result set.

Can you please advise.

Thanks,
Komala

e.g.  checkType==TAKE&orderby=checkId

cz.jirutka.rsql.parser.TokenMgrError: Lexical error at line 1, column 29.  Encountered: ";" (59), after : "=checkId"

I got the above error.
how to implement sorting.
Can you please advise.```