Skip to main content
This page shows you how to create an index with various configurations.

Create an index from scratch

The simplest way to create an index is to provide the index name and the field mappings.
AIMP_PROJECT_API_KEY="YOUR_API_KEY"

curl -i -X POST "https://{baseUrl}/{apiVersion}/projects/{projectId}/indexes" \
  -H "content-type: application/json" \
  -H "x-api-key: $AIMP_PROJECT_API_KEY" \
  -d '{
        "indexName": "example-std-index",
        "mappings": {
          "url": {
            "type": "keyword"
          },
          "author": {
            "type": "keyword"
          }
        }
      }'
In this case, the index is created with the standard class configuration by default. You can change the index class by explicitly providing the indexClass parameter.
AIMP_PROJECT_API_KEY="YOUR_API_KEY"

curl -i -X POST "https://{baseUrl}/{apiVersion}/projects/{projectId}/indexes" \
  -H "content-type: application/json" \
  -H "x-api-key: $AIMP_PROJECT_API_KEY" \
  -d '{
        "indexName": "example-ia-index",
        "indexClass": "INFREQUENT_ACCESS",
        "mappings": {
          "url": {
            "type": "keyword"
          },
          "author": {
            "type": "keyword"
          }
        }
      }'

Create an index cloned from another index

You can create an index cloned from an existing index by simply providing information related to the source index.
AIMP_TARGET_PROJECT_API_KEY="YOUR_TARGET_API_KEY"
AIMP_SOURCE_PROJECT_API_KEY="YOUR_SOURCE_API_KEY"

curl -i -X POST "https://{baseUrl}/{apiVersion}/projects/{projectId}/indexes" \
  -H "content-type: application/json" \
  -H "x-api-key: $AIMP_TARGET_PROJECT_API_KEY" \
  -d '{
        "indexName": "example-index",
        "sourceProjectId": "example-source-project-id",
        "sourceProjectApiKey": $AIMP_SOURCE_PROJECT_API_KEY,
        "sourceIndexName": "example-source-index-name"
      }'
As shown above example, specifying mappings is optional when cloning an index. You can pass mappings object only with additional mappings based on the original index’s mappings. Deleting or modifying the original index’s mappings is not allowed.