# Indexes
The /indexes route allows you to create, manage, and delete your indexes.
# List all indexes
/indexesList all indexes. Results can be paginated by using the offset and limit query parameters.
# Query parameters
| Query parameter | Description | Default value |
|---|---|---|
| offset | Number of indexes to skip | 0 |
| limit | Number of indexes to return | 20 |
# Example
curl \
-X GET 'http://localhost:7700/indexes?limit=3'
# Response: 200 Ok
{
"results": [
{
"uid": "books",
"createdAt": "2022-03-08T10:00:27.377346Z",
"updatedAt": "2022-03-08T10:00:27.391209Z",
"primaryKey": "id"
},
{
"uid": "meteorites",
"createdAt": "2022-03-08T10:00:44.518768Z",
"updatedAt": "2022-03-08T10:00:44.582083Z",
"primaryKey": "id"
},
{
"uid": "movies",
"createdAt": "2022-02-10T07:45:15.628261Z",
"updatedAt": "2022-02-21T15:28:43.496574Z",
"primaryKey": "id"
}
],
"offset": 0,
"limit": 3,
"total": 5
}
# Get one index
/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",
"createdAt": "2022-02-10T07:45:15.628261Z",
"updatedAt": "2022-02-21T15:28:43.496574Z",
"primaryKey": "id"
}
# Create an index
/indexesCreate 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
{
"taskUid": 0,
"indexUid": "movies",
"status": "enqueued",
"type": "indexCreation",
"enqueuedAt": "2021-08-12T10:00:00.000000Z"
}
You can use the response's taskUid to track the status of your request.
# Update an index
/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 PATCH 'http://localhost:7700/indexes/movies' \
-H 'Content-Type: application/json' \
--data-binary '{ "primaryKey": "id" }'
# Response: 202 Accepted
{
"taskUid": 1,
"indexUid": "movies",
"status": "enqueued",
"type": "indexUpdate",
"enqueuedAt": "2021-08-12T10:00:00.000000Z"
}
You can use the response's taskUid to track the status of your request.
# Delete an index
/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
{
"taskUid": 1,
"indexUid": "movies",
"status": "enqueued",
"type": "indexDeletion",
"enqueuedAt": "2021-08-12T10:00:00.000000Z"
}
You can use the response's taskUid to track the status of your request.