# Indexes

The /indexes route allows you to create, manage, and delete your indexes.

Learn more about indexes.

# List all indexes

GET
/indexes

List all indexes.

# Example

curl \
  -X GET 'http://localhost:7700/indexes'

# Response: 200 Ok

[
  {
    "uid": "books",
    "name": "books",
    "createdAt": "2022-03-08T10:00:27.377346Z",
    "updatedAt": "2022-03-08T10:00:27.391209Z",
    "primaryKey": "id"
  },
  {
    "uid": "meteorites",
    "name": "meteorites",
    "createdAt": "2022-03-08T10:00:44.518768Z",
    "updatedAt": "2022-03-08T10:00:44.582083Z",
    "primaryKey": "id"
  },
  {
    "uid": "movies",
    "name": "movies",
    "createdAt": "2022-02-10T07:45:15.628261Z",
    "updatedAt": "2022-02-21T15:28:43.496574Z",
    "primaryKey": "id"
  }
]  

# Get one index

GET
/indexes/{index_uid}

Get information about an index. The index uid is required.

# Example

curl \
  -X GET 'http://localhost:7700/indexes/movies'

# Response: 200 Ok

{
  "uid": "movies",
  "name": "movies",
  "createdAt": "2022-02-10T07:45:15.628261Z",
  "updatedAt": "2022-02-21T15:28:43.496574Z",
  "primaryKey": "id"
}

# Create an index

POST
/indexes

Create an index. This endpoint accepts two arguments: uid and primaryKey.

If you do not supply a value for primaryKey, Meilisearch will try to infer your dataset's unique identifier from the first document you add to the index.

NOTE

If you try to add documents or settings to an index that does not exist, Meilisearch will automatically create it for you. This is called implicit index creation.

Creating an index is an asynchronous task. You can read more about asynchronous operations in our dedicated guide.

# Body

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

# Example

curl \
  -X POST 'http://localhost:7700/indexes' \
  -H 'Content-Type: application/json' \
  --data-binary '{
    "uid": "movies",
    "primaryKey": "id"
  }'

# Response: 202 Accepted

{
  "uid": 0,
  "indexUid": "movies",
  "status": "enqueued",
  "type": "indexCreation",
  "enqueuedAt": "2021-08-12T10:00:00.000000Z"
}

You can use the response's uid to track the status of your request.

# Update an index

PUT
/indexes/{index_uid}

Update an index's primary key. The index uid is required.

You can freely update the primary key of an index as long as it contains no documents.

To change the primary key of an index that already contains documents, you must first delete all documents in that index. You may then change the primary key, and finally, index your dataset again.

NOTE

It is not possible to change an index's uid.

This is an asynchronous task. You can read more about asynchronous operations in our dedicated guide.

# Body

Variable Description
primaryKey The primary key of the documents

# Example

curl \
  -X PUT 'http://localhost:7700/indexes/movies' \
  -H 'Content-Type: application/json' \
  --data-binary '{ "primaryKey": "id" }'

# Response: 202 Accepted

{
  "uid": 1,
  "indexUid": "movies",
  "status": "enqueued",
  "type": "indexUpdate",
  "enqueuedAt": "2021-08-12T10:00:00.000000Z"
}

You can use the response's uid to track the status of your request.

# Delete an index

DELETE
/indexes/{index_uid}

Delete an index. The index uid is required.

This is an asynchronous task. You can read more about asynchronous operations in our dedicated guide.

# Example

curl \
  -X DELETE 'http://localhost:7700/indexes/movies'

# Response: 202 Accepted

{
  "uid": 1,
  "indexUid": "movies",
  "status": "enqueued",
  "type": "indexDeletion",
  "enqueuedAt": "2021-08-12T10:00:00.000000Z"
}

You can use the response's uid to track the status of your request.