/indexes route allows you to create, manage, and delete your indexes.
Learn more about indexes.
Index object
| Name | Type | Default value | Description |
|---|---|---|---|
uid | String | N/A | Unique identifier of the index. Once created, it cannot be changed |
createdAt | String | N/A | Creation date of the index, represented in RFC 3339 format. Auto-generated on index creation |
updatedAt | String | N/A | Latest date of index update, represented in RFC 3339 format. Auto-generated on index creation or update |
primaryKey | String / null | null | Primary key of the index. If not specified, Meilisearch guesses your primary key from the first document you add to the index |
List all indexes
GET
/indexes
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 |
Response
| Name | Type | Description |
|---|---|---|
results | Array | An array of indexes |
offset | Integer | Number of indexes skipped |
limit | Integer | Number of indexes returned |
total | Integer | Total number of indexes |
Example
Response: 200 Ok
Get one index
GET
/indexes/{index_uid}
Path parameters
| Name | Type | Description |
|---|---|---|
index_uid * | String | uid of the requested index |
Example
Response: 200 Ok
Create an index
POST
/indexes
Body
| Name | Type | Default value | Description |
|---|---|---|---|
uid * | String | N/A | uid of the requested index |
primaryKey | String / null | null | Primary key of the requested index |
Example
Response: 202 Accepted
taskUid to track the status of your request.
Update an index
PATCH
/indexes/{index_uid}
Path parameters
| Name | Type | Description |
|---|---|---|
index_uid * | String | uid of the requested index |
Body
| Name | Type | Default value | Description |
|---|---|---|---|
primaryKey * | String / null | N/A | Primary key of the requested index |
uid * | String / null | N/A | New uid of the requested index |
Example
Response: 202 Accepted
taskUid to track the status of your request.
Delete an index
DELETE
/indexes/{index_uid}
Path parameters
| Name | Type | Description |
|---|---|---|
index_uid * | String | uid of the requested index |
Example
Response: 202 Accepted
taskUid to track the status of your request.
Swap indexes
POST
/swap-indexes
indexA and indexB will also replace every mention of indexA by indexB and vice-versa in the task history. enqueued tasks are left unmodified.
To learn more about index swapping, refer to this short guide.
Body
An array of objects with the following fields:| Name | Type | Default value | Description |
|---|---|---|---|
indexes | Array of strings | N/A | Array of the two indexUids to be swapped |
rename | Boolean | false | If true, renames an index instead of swapping it |
indexes array must contain only two elements: the indexUids of the two indexes to be swapped. Sending an empty array ([]) is valid, but no swap operation will be performed.
Use rename: false if you are swapping two existing indexes. Use rename: true if the second index in your array does not exist.
Example
Response
Since
indexSwap is a global task, the indexUid is always null.taskUid to track the status of your request.