# 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

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

# 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/:uid

Get information about an index.

# Path variables

Variable Description
uid The index UID

# Example

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

# 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 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 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": "movie_id"
}

# Example

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

# 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/:uid

Update an index's primary key.

If a primary key wasn't explicitly chosen during index creation, you can use this route to configure it. If you are unsure whether an index's primary key has already been configured, you can use the get index endpoint to verify it.

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.

# Path variables

Variable Description
uid The index UID

# Body

Variable Description
primaryKey The primary key of the documents

# Example

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

# Response: 202 Accepted

{
  "uid": 1,
  "indexUid": "movie_review",
  "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/:uid

Delete an index.

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

# Path variables

Variable Description
uid The index UID

# 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.