--
:api: get-records 
:request: GetRecordsRequest
:response: GetRecordsResponse
--
[role="xpack"]
[id="{upid}-{api}"]
=== Get records API

Retrieves one or more record results.
It accepts a +{request}+ object and responds with a +{response}+ object.

[id="{upid}-{api}-request"]
==== Get records request

A +{request}+ object gets created with an existing non-null `jobId`.

["source","java",subs="attributes,callouts,macros"]
--------------------------------------------------
include-tagged::{doc-tests-file}[{api}-request]
--------------------------------------------------
<1> Constructing a new request referencing an existing `jobId`.

==== Optional arguments
The following arguments are optional:

["source","java",subs="attributes,callouts,macros"]
--------------------------------------------------
include-tagged::{doc-tests-file}[{api}-desc]
--------------------------------------------------
<1> If `true`, the records are sorted in descending order. Defaults to `false`.

["source","java",subs="attributes,callouts,macros"]
--------------------------------------------------
include-tagged::{doc-tests-file}[{api}-end]
--------------------------------------------------
<1> Records with timestamps earlier than this time will be returned.

["source","java",subs="attributes,callouts,macros"]
--------------------------------------------------
include-tagged::{doc-tests-file}[{api}-exclude-interim]
--------------------------------------------------
<1> If `true`, interim results will be excluded. Defaults to `false`.

["source","java",subs="attributes,callouts,macros"]
--------------------------------------------------
include-tagged::{doc-tests-file}[{api}-page]
--------------------------------------------------
<1> The page parameters `from` and `size`. `from` specifies the number of
records to skip. `size` specifies the maximum number of records to get. Defaults
to `0` and `100` respectively.

["source","java",subs="attributes,callouts,macros"]
--------------------------------------------------
include-tagged::{doc-tests-file}[{api}-record-score]
--------------------------------------------------
<1> Records with record_score greater or equal than this value will be returned.

["source","java",subs="attributes,callouts,macros"]
--------------------------------------------------
include-tagged::{doc-tests-file}[{api}-sort]
--------------------------------------------------
<1> The field to sort records on. Defaults to `record_score`.

["source","java",subs="attributes,callouts,macros"]
--------------------------------------------------
include-tagged::{doc-tests-file}[{api}-start]
--------------------------------------------------
<1> Records with timestamps on or after this time will be returned.

include::../execution.asciidoc[]

[id="{upid}-{api}-response"]
==== Get records response

The returned +{response}+ contains the requested records:

["source","java",subs="attributes,callouts,macros"]
--------------------------------------------------
include-tagged::{doc-tests-file}[{api}-response]
--------------------------------------------------
<1> The count of records that were matched.
<2> The records retrieved.