If you have not enabled the auto indexing feature of Alibaba Cloud Elasticsearch, before you manage a document, you must create an index for the document. This topic describes how to use Alibaba Cloud Elasticsearch (ES) to create an index.

Use the Kibana console to access Alibaba Cloud Elasticsearch, and send the following request to create an index:
PUT /my_index
{

    "settings" : {
      "index" : {
        "number_of_shards" : "5",
        "number_of_replicas" : "1"
      }
    },
    "mappings" : {
        "my_type" : {
            "properties" : {
              "post_date": {          
                   "type": "date"       
               },
              "tags": {
                   "type": "keyword"
               },
                "title" : {
                    "type" : "text",
                    "analyzer" : "cjk"
                }
            }
        }
    }
}
Notice
  • The preceding request is only an example. You can customize the parameters as needed. For more information, see the official Elasticsearch documentation.
  • You can configure the YML configuration file of your Elasticsearch instance to enable auto indexing. After auto indexing is enabled, when you create a document, the system automatically creates an index for the document. Auto indexing is only used for testing purposes. We recommend that you do not use auto indexing in production.
  • Mapping types will be deprecated in Alibaba Cloud Elasticsearch V7.0.0 and later versions. Versions earlier than Elasticsearch V7.0.0 still support mapping types. For more information, see the official Elasticsearch documentation.

The preceding example creates an index named my_index. The type of the index is my_type. The index is split into five shards, has one replica, and uses the cjk analyzer.

If the request is successful, the following result is returned:
{
  "acknowledged" : true,
  "shards_acknowledged" : true,
  "index" : "my_index"
}