Get Documents

POST /indexes/{indexUid}/documents/fetch

Get documents by batch.

application/json

Body Required

  • offset number

    Number of documents to skip.

    Default value is 0.

  • limit number

    Maximum number of documents returned.

    Default value is 20.

  • fields array[string]

    Array of attributes whose fields will be present in the returned documents. By default all attributes will be returned.

    Default value is ["*"].

  • filter array[string] | string | array[array | string]
    One of:

    Attribute(s) to filter on.

    Can be made of 3 syntaxes

    • Nested Array: ["something > 1", "genres=comedy", ["genres=horror", "title=batman"]]
    • String: "something > 1 AND genres=comedy AND (genres=horror OR title=batman)"
    • Mixed: ["something > 1 AND genres=comedy", "genres=horror OR title=batman"]


    _geoRadius({lat}, {lng}, {distance_in_meters}) and _geoBoundingBox([{lat, lng}], [{lat}, {lng}]) built-in filter rules can be used to filter documents within geo shapes.


    Attribute(s) used in filter should be declared as filterable attributes. See Filtering and Faceted Search.

    Format of each should match the following pattern: ^[^:]+:[^:]+$.

    Attribute(s) to filter on.

    Can be made of 3 syntaxes

    • Nested Array: ["something > 1", "genres=comedy", ["genres=horror", "title=batman"]]
    • String: "something > 1 AND genres=comedy AND (genres=horror OR title=batman)"
    • Mixed: ["something > 1 AND genres=comedy", "genres=horror OR title=batman"]


    _geoRadius({lat}, {lng}, {distance_in_meters}) and _geoBoundingBox([{lat, lng}], [{lat}, {lng}]) built-in filter rules can be used to filter documents within geo shapes.


    Attribute(s) used in filter should be declared as filterable attributes. See Filtering and Faceted Search.

    Format should match the following pattern: ^[^:]+:[^:]+$.

    Attribute(s) to filter on.

    Can be made of 3 syntaxes

    • Nested Array: ["something > 1", "genres=comedy", ["genres=horror", "title=batman"]]
    • String: "something > 1 AND genres=comedy AND (genres=horror OR title=batman)"
    • Mixed: ["something > 1 AND genres=comedy", "genres=horror OR title=batman"]


    _geoRadius({lat}, {lng}, {distance_in_meters}) and _geoBoundingBox([{lat, lng}], [{lat}, {lng}]) built-in filter rules can be used to filter documents within geo shapes.


    Attribute(s) used in filter should be declared as filterable attributes. See Filtering and Faceted Search.

Responses

  • 200 application/json

    Ok

    Hide response attributes Show response attributes object
    • results array[object] Required

      A document made of attribute. The maximum number of attribute for a document is 65,535.

      Hide results attribute Show results attribute object
    • limit integer Required

      Limit given for the query. If limit is not provided as a query parameter, this parameter displays the default limit value.

    • offset integer Required

      Offset given for the query. If offset is not provided as a query parameter, this parameter displays the default offset value.

    • total integer Required

      Total number of browsable results using offset/limit parameters for the given resource.

  • 401 application/json

    Unauthorized

    Hide response attributes Show response attributes object
  • 404

    Not Found

POST /indexes/{indexUid}/documents/fetch
curl \
 -X POST https://example.meilisearch.com:7700/indexes/{indexUid}/documents/fetch \
 -H "Authorization: Bearer $ACCESS_TOKEN" \
 -H "Content-Type: application/json" \
 -d '{"offset":2,"limit":5,"fields":["name","picture"],"filter":"doggo = \"bernese mountain\""}'
Request example
{
  "offset": 2,
  "limit": 5,
  "fields": [
    "name",
    "picture"
  ],
  "filter": "doggo = \"bernese mountain\""
}
Response examples (200)
{
  "results": [
    {
      "id": 25684,
      "title": "American Ninja 5",
      "poster": "https://image.tmdb.org/t/p/w1280/iuAQVI4mvjI83wnirpD8GVNRVuY.jpg",
      "overview": "When a scientists daughter is kidnapped, American Ninja, attempts to find her, but this time he teams up with a youngster he has trained in the ways of the ninja.",
      "release_date": 725846400
    },
    {
      "id": 45881,
      "title": "The Bridge of San Luis Rey",
      "poster": "https://image.tmdb.org/t/p/w500/4X7quIcdkc24Cveg5XdpfRqxtYA.jpg",
      "overview": "The Bridge of San Luis Rey is American author Thornton Wilder's second novel, first published in 1927 to worldwide acclaim. It tells the story of several interrelated people who die in the collapse of an Inca rope-fiber suspension bridge in Peru, and the events that lead up to their being on the bridge.[ A friar who has witnessed the tragic accident then goes about inquiring into the lives of the victims, seeking some sort of cosmic answer to the question of why each had to die. The novel won the Pulitzer Prize in 1928.",
      "release_date": 1072915200
    }
  ],
  "limit": 20,
  "offset": 0,
  "total": 2
}
Response examples (401)
{
  "message": "The Authorization header is missing. It must use the bearer authorization method.",
  "code": "missing_authorization_header",
  "type": "auth",
  "link": "https://docs.meilisearch.com/errors#missing_authorization_header"
}