Skip to main content

Content type

Any API request with a payload (--data-binary) requires a Content-Type header. Content type headers indicate the media type of the resource, helping the client process the response body correctly. Meilisearch currently supports the following formats:
  • Content-Type: application/json for JSON
  • Content-Type: application/x-ndjson for NDJSON
  • Content-Type: text/csv for CSV
Only the add documents and update documents endpoints accept NDJSON and CSV. For all others, use Content-Type: application/json.

Content encoding

The Content-Encoding header indicates the media type is compressed by a given algorithm. Compression improves transfer speed and reduces bandwidth consumption by sending and receiving smaller payloads. The Accept-Encoding header, instead, indicates the compression algorithm the client understands. Meilisearch supports the following compression methods:
  • br: uses the Brotli algorithm
  • deflate: uses the zlib structure with the deflate compression algorithm
  • gzip: uses the gzip algorithm

Request compression

The code sample below uses the Content-Encoding: gzip header, indicating that the request body is compressed using the gzip algorithm:
 cat ~/movies.json | gzip | curl -X POST 'MEILISEARCH_URL/indexes/movies/documents' --data-binary @- -H 'Content-Type: application/json' -H 'Content-Encoding: gzip'

Response compression

Meilisearch compresses a response if the request contains the Accept-Encoding header. The code sample below uses the gzip algorithm:
curl -sH 'Accept-encoding: gzip' 'MEILISEARCH_URL/indexes/movies/search' | gzip -

Search metadata

You may use an optional Meili-Include-Metadata header when performing search and multi-search requests:
curl -X POST 'http://localhost:7700/indexes/INDEX_NAME/search' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer MEILISEARCH_API_KEY' \
  -H 'Meili-Include-Metadata: true' \
  -d '{"q": ""}'
Meilisearch Cloud includes this header by default. Responses will include a metadata object:
{
  "hits": [  ],
  "metadata": {
    "queryUid": "0199a41a-8186-70b3-b6e1-90e8cb582f35",
    "indexUid": "INDEX_NAME",
    "primaryKey": "INDEX_PRIMARY_KEY"
  }
}
metadata contains the following fields:
FieldTypeDescription
queryUidUUID v7Unique identifier for the query
indexUidStringIndex identifier
primaryKeyStringPrimary key field name, if index has a primary key
remoteStringRemote instance name, if request targets a remote instance
A search refers to a single HTTP search request. Every search request is assigned a requestUid. A query UID is a combination of q and indexUid.In the context of multi-search, for any given searchUid there may be multiple queryUid values.