export #
Export searched documents.
This method behaves like a document:search
except that it scrolls and formats the searched results in one of the supported format (csv
, jsonl
) then returns everything as an HTTP Stream,
that can either be downloaded directly from a browser or any scripts.
This method also supports the Koncorde Filters DSL to match documents by passing the lang
argument with the value koncorde
.
Koncorde filters will be translated into an Elasticsearch query.
The scroll
parameter represents the maximum time needed for the client to download a page of size
results.
You should try with smaller pages of results if you experienced download problems.
Koncorde bool
operator and regexp
clause are not supported for search queries.
This method only supports the HTTP Protocol
Query Syntax #
HTTP #
URL: http://kuzzle:7512/<index>/<collection>/_export[?format=<export format>][&size=<int>][&scroll=<time to live>][&lang=<query language>]
Method: GET
Body:
{
"query": {
// ...
},
"aggregations": {
// ...
},
"sort": [
// ...
],
"fields": [
// ...
]
}
You can also access this route with the GET
verb:
URL: http://kuzzle:7512/<index>/<collection>/_export[?format=<export format>][&size=<int>][&scroll=<time to live>][&lang=<query language>]
Method: GET
Other protocols #
{
"index": "<index>",
"collection": "<collection>",
"controller": "document",
"action": "search",
"body": {
"query": {
// ...
},
"aggregations": {
// ...
},
"sort": [
// ...
],
"fields": [
// ...
]
},
// optional:
"size": <page size>,
"scroll": "<scroll duration>",
"lang": "<query language>",
"format": "<export format>",
"fieldsName": {
"<field path>": "<field name>"
}
}
Arguments #
collection
: collection nameindex
: index name
Optional: #
separator
: This option is only supported for theCSV
format, it defines which character sequence will be used to format the CSV documentsfieldsName
: This option is only supported for theCSV
format, it defines how fields path should be renamed, if not present the field path will be used.scroll
: This option must be set with a time duration (opens new window), at the end of which the cursor is destroyed.size
: set the maximum number of documents returned per result page. By default it's10
.lang
: specify the query language to use. By default, it'selasticsearch
butkoncorde
can also be used.format
: Set the format that should be used to export the documents. (csv
,jsonl
)
Body properties #
Optional: #
query
: the search query itself, using the ElasticSearch Query DSL (opens new window) or the Koncorde Filters DSL syntax.aggregations
: control how the search result should be aggregated (opens new window)sort
: contains a list of fields, used to sort search results (opens new window), in order of importancefields
: control which field should be exported, using lodash syntax.
An empty body matches all documents in the queried collection.
Only the following fields are available in the top level of the search body: aggregations
, aggs
, collapse
, explain
, from
, highlight
, query
, search_timeout
, size
, sort
, _name
, _source
, _source_excludes
, _source_includes
Response #
Returns an HTTP Stream that contains the formatted documents