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.
If you want to expose the exported documents in HTTP, you will need to create a <a> element and add a single use token in the link jwt argument.
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: POST
Body:{
"query": {
// ...
},
"aggregations": {
// ...
},
"sort": [
// ...
],
"fields": [
// ["name", "age"]
],
"fieldsName": {
// "name": "Customer Name"
}
}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>][&searchBody=<query, sort>][&fields=<fields to export>][&fieldsName=<header of each exported field>]
Method: GETIt's possible to pass arguments that are usually in the body into the query string in JSON format. Following arguments are available: query, fields and fieldsName.
Other protocols #
{
"index": "<index>",
"collection": "<collection>",
"controller": "document",
"action": "export",
"body": {
"query": {
// ...
},
"aggregations": {
// ...
},
"sort": [
// ...
],
"fields": [
// ["name", "age"]
]
},
// optional:
"size": <page size>,
"scroll": "<scroll duration>",
"lang": "<query language>",
"format": "<export format>",
"fieldsName": {
"name": "Customer Name"
}
}Arguments #
collection: collection nameindex: index name
Optional: #
separator: This option is only supported for theCSVformat, it defines which character sequence will be used to format the CSV documentsfields: This option is only supported for theCSVformat, it defines which fields should be exportedfieldsName: This option is only supported for theCSVformat, 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, 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'selasticsearchbutkoncordecan 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 or the Koncorde Filters DSL syntax.aggregations: control how the search result should be aggregatedsort: contains a list of fields, used to sort search results, 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, fields, from, highlight, query, search_timeout, size, sort, _name, _source, _source_excludes, _source_includes
Response #
Returns an HTTP Stream that contains the formatted documents
