Core
API v2.x
2

export #

Available since 2.17.0

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 #

Copied to clipboard!
URL: http://kuzzle:7512/<index>/<collection>/_export[?format=<export format>][&size=<int>][&scroll=<time to live>][&lang=<query language>]
Method: GET
Body:
Copied to clipboard!
{
  "query": {
    // ...
  },
  "aggregations": {
    // ...
  },
  "sort": [
    // ...
  ],
  "fields": [
    // ...
  ]
}

You can also access this route with the GET verb:

Copied to clipboard!
URL: http://kuzzle:7512/<index>/<collection>/_export[?format=<export format>][&size=<int>][&scroll=<time to live>][&lang=<query language>]
Method: GET

Other protocols #

Copied to clipboard!
{
  "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 name
  • index: index name

Optional: #

  • separator: This option is only supported for the CSV format, it defines which character sequence will be used to format the CSV documents
  • fieldsName: This option is only supported for the CSV 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, at the end of which the cursor is destroyed.
  • size: set the maximum number of documents returned per result page. By default it's 10.
  • lang: specify the query language to use. By default, it's elasticsearch but koncorde can also be used.
  • format: Set the format that should be used to export the documents. (csv, jsonl)

Body properties #

Optional: #

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