Get SQL search results
- POST also GET /_sql
Run an SQL request.
Required authorization
- Index privileges read
Request body
-
allow_partial_search_resultsboolean · default: false -
If
true, the response has partial results when there are shard request timeouts or shard failures. Iffalse, the API returns an error with no partial results. -
catalogstring -
The default catalog (cluster) for queries. If unspecified, the queries execute on the data in the local cluster only.
-
columnarboolean · default: false -
If
true, the results are in a columnar fashion: one row represents all the values of a certain column from the current page of results. The API supports this parameter only for CBOR, JSON, SMILE, and YAML responses. - Reference
-
cursorstring -
The cursor used to retrieve a set of paginated results. If you specify a cursor, the API only uses the
columnarandtime_zonerequest body parameters. It ignores other request body parameters. -
fetch_sizenumber · default: 1000 -
The maximum number of rows (or entries) to return in one response.
-
field_multi_value_leniencyboolean · default: false -
If
false, the API returns an exception when encountering multiple values for a field. Iftrue, the API is lenient and returns the first value from the array with no guarantee of consistent results. -
filterQuery · default: none -
The Elasticsearch query DSL for additional filtering.
-
keep_on_completionboolean · default: false -
If
true, Elasticsearch stores synchronous searches if you also specify thewait_for_completion_timeoutparameter. Iffalse, Elasticsearch only stores async searches that don't finish before thewait_for_completion_timeout. -
page_timeoutstring · default: 45s -
The minimum retention period for the scroll cursor. After this time period, a pagination request might fail because the scroll cursor is no longer available. Subsequent scroll requests prolong the lifetime of the scroll cursor by the duration of
page_timeoutin the scroll request. -
runtime_mappingsobject -
One or more runtime fields for the search request. These fields take precedence over mapped fields with the same name.
-
wait_for_completion_timeoutstring -
The period to wait for complete results. It defaults to no timeout, meaning the request waits for complete search results. If the search doesn't finish within this period, the search becomes async.
To save a synchronous search, you must specify this parameter and the
keep_on_completionparameter.
Response
-
cursorstring -
The cursor for the next set of paginated results. For CSV, TSV, and TXT responses, this value is returned in the
CursorHTTP header. -
idstring -
The identifier for the search. This value is returned only for async and saved synchronous searches. For CSV, TSV, and TXT responses, this value is returned in the
Async-IDHTTP header. -
is_runningboolean -
If
true, the search is still running. Iffalse, the search has finished. This value is returned only for async and saved synchronous searches. For CSV, TSV, and TXT responses, this value is returned in theAsync-partialHTTP header. -
is_partialboolean -
If
true, the response does not contain complete search results. Ifis_partialistrueandis_runningistrue, the search is still running. Ifis_partialistruebutis_runningisfalse, the results are partial due to a failure or timeout. This value is returned only for async and saved synchronous searches. For CSV, TSV, and TXT responses, this value is returned in theAsync-partialHTTP header.