How do I implement count, group by, and other commonly used SQL constructs using GET REST API calls and still adhering to good standards? I haven't seen any documentation that describes how to do this. Are there any standards already in place? Any help would be appreciated. Thanks.
- 
                    SOLR has a REST API supporting complex querying: https://lucene.apache.org/solr/guide/7_1/json-request-api.html – Bart Kiers Sep 20 '18 at 18:07
- 
                    Thanks Bart. Do you know if REST has any standards for creating complex queries? Isn't there any documentation that informs developers how to do this? – Foobar Sep 20 '18 at 18:13
1 Answers
From the other answer, I think you are looking for this:
POST /books/search
    {
        "keywords": "...",
        "yearRange": {"from": 1945, "to": 2003},
        "genre": "..."
    }
There is nothing un-RESTful about this endpoint. It accepts data (entity) in the form of the request body. That data is the Search Criteria - a DTO like any other. This endpoint produces a resource (entity) in response to the request: Search Results. The search results resource is a temporary one, served immediately to the client, without a redirect, and without being exposed from some other canonical url.
It's still REST, except the entities aren't books - the request entity is book search criteria, and the response entity is book search results.
Look at this answer for more details: https://stackoverflow.com/a/31984477/37083
Using this structure you can easily expand the search with other complex items
POST /books/search
    {
        "keywords": "...",
        "yearRange": {"from": 1945, "to": 2003},
        "genre": "...",
        "groupby": "year",
        "countby": "keywords"
    }
 
    
    - 2,510
- 4
- 35
- 55
