# Indexes

An index is an entity that gathers a set of documents with its own settings.

Learn more about indexes.

# List all indexes

GET
/indexes

List all indexes.

# Example

# Response: 200 Ok

[
  {
    "uid": "movies",
    "primaryKey": "movie_id",
    "createdAt": "2019-11-20T09:40:33.711324Z",
    "updatedAt": "2019-11-20T10:16:42.761858Z"
  },
  {
    "uid": "movie_reviews",
    "primaryKey": null,
    "createdAt": "2019-11-20T09:40:33.711324Z",
    "updatedAt": "2019-11-20T10:16:42.761858Z"
  }
]

# Get one index

GET
/indexes/:index_uid

Get information about an index.

# Path Variables

Variable Description
index_uid The index UID

# Example

# Response: 200 Ok

{
  "uid": "movies",
  "primaryKey": "movie_id",
  "createdAt": "2019-11-20T09:40:33.711324Z",
  "updatedAt": "2019-11-20T10:16:42.761858Z"
}

# Create an index

POST
/indexes

Create an index.

This route takes as parameter an unique uid and optionally the primary key.

NOTE

An index is automatically created when adding documents or settings to an index that does not already exist.

# Body

Variable Description
index_uid The index unique identifier (mandatory)
primaryKey The of the documents
{
  "uid": "movies",
  "primaryKey": "movie_id"
}

# Example

# Response: 201 created

{
  "uid": "movies",
  "primaryKey": "movie_id",
  "createdAt": "2019-11-20T09:40:33.711476Z",
  "updatedAt": "2019-11-20T09:40:33.711476Z"
}

# Update an index

PUT
/indexes/:index_uid

Update an index.

# Path Variables

Variable Description
index_uid The index UID

# Body

Variable Description
primaryKey The of the documents

The uid of an index cannot be changed.
The primaryKey can be added if it does not already exist (to know if it has been set, use the get index route).

There are many ways in MeiliSearch to set the primary key.

# Example

# Response: 200 Ok

{
  "uid": "movie_review",
  "primaryKey": "movie_review_id",
  "createdAt": "2019-11-20T09:40:33.711324Z",
  "updatedAt": "2019-11-20T10:16:42.761858Z"
}

# Delete an index

DELETE
/indexes/:index_uid

Delete an index.

# Path Variables

Variable Description
index_uid The index UID

# Example

# Response: 204 No Content

Last Updated: 11/10/2020, 3:40:26 PM