vtlim commented on code in PR #14589: URL: https://github.com/apache/druid/pull/14589#discussion_r1276828469
########## docs/api-reference/json-querying-api.md: ########## @@ -23,14 +23,872 @@ sidebar_label: JSON querying ~ under the License. --> -This document describes the API endpoints to submit JSON-based [native queries](../querying/querying.md) to Apache Druid. +This topic describes the API endpoints to submit JSON-based [native queries](../querying/querying.md) to Apache Druid. -## Queries +In this topic, `http://SERVICE_IP:SERVICE_PORT` is a placeholder for the server address of deployment and the service port. For example, on the quickstart configuration, replace `http://ROUTER_IP:ROUTER_PORT` with `http://localhost:8888`. -`POST /druid/v2/` -The endpoint for submitting queries. Accepts an option `?pretty` that pretty prints the results. +## Submit a query -`POST /druid/v2/candidates/` +Submits a JSON-based native query. -Returns segment information lists including server locations for the given query. \ No newline at end of file +Queries are composed of various JSON properties and Druid has different types of queries for different use cases. The possible types of queries are: `timeseries`, `topN`, `groupBy`, `timeBoundaries`, `segmentMetadata`, `datasourceMetadata`, `scan`, and `search`. For guidance on constructing the requests and choosing query types, see [available native queries](../querying/querying.md#available-queries). + +### URL + +<code class="postAPI">POST</code> <code>/druid/v2/</code> + +### Query parameters + +* `pretty` (optional) + * Druid returns the response in a pretty-printed format using indentation and line breaks. + +### Responses + +<!--DOCUSAURUS_CODE_TABS--> + +<!--200 SUCCESS--> + +*Successfully submitted query* + +<!--400 BAD REQUEST--> + +*Error thrown due to bad query. Returns a JSON object detailing the error with the following format:* + +```json +{ + "error": "A well-defined error code.", + "errorMessage": "A message with additional details about the error.", + "errorClass": "Class of exception that caused this error.", + "host": "The host on which the error occurred." +} +``` +For more information on possible error messages, see [query execution failures](../querying/querying.md#query-execution-failures). + +<!--END_DOCUSAURUS_CODE_TABS--> + +--- + +### Sample request: `topN` + +The following example submits a JSON query of the `topN` type to retrieve a ranked list of users and their post views. Review Comment: ```suggestion The following example shows a `topN` query. The query analyzes the `social_media` datasource to return the top five users from the `username` dimension with the highest number of views from the `views` metric. ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
