1. Create an index (test_index)
curl -XPUT "http://192.168.99.1:9200/test_index"
2. Create an index and specify the number of shards and replicas
curl -XPUT "http://192.168.99.1:9200/test_index" -d' { "settings": { "number_of_shards": 2, "number_of_replicas": 1 } }'
3. Create an index (test_index), create a type (product), and specify the mapping data
curl -XPUT "http://192.168.99.1:9200/test_index" -d' { "mappings": { "product" : { "properties": { "id" : { "type": "text", "index": "not_analyzed" }, "userName" : { "type": "text", "index": "analyzed" } } } } }'
4. The value of the field in the mapping of the existing type cannot be modified, but it can be added
curl -XPOST "http://192.168.99.1:9200/test_index/_mapping/product" -d' { "properties": { "price" : { "type": "long" } } }'
5. Add a new type to the existing index
curl -XPOST "http://192.168.99.1:9200/test_index/_mapping/add_new_type" -d' { "properties": { "field01" : { "type": "text" } } }'
6. Close the index
curl -XPOST "http://192.168.99.1:9200/test_index/_close"
7. Open the index
curl -XPOST "http://192.168.99.1:9200/test_index/_open"
8. Get the information under the index
curl -XGET "http://192.168.99.1:9200/test_index"
9. View index statistics
curl -XGET "http://192.168.99.1:9200/test_index/_stats"
10. Get the mappings of the index
curl -XGET "http://192.168.99.1:9200/test_index/_mappings"
11. Delete the index
curl -XDELETE "http://192.168.99.1:9200/test_index"
12. Cancel the automatic index creation of es and modify the configuration file of es
action.auto_create_index: false
13. Create aliases for indexes (_alias is used for a single operation, while _aliases is used for multiple operations, maintaining atomicity)
method one:
Method two:
curl -XPUT "http://192.168.99.1:9200/test_index/_alias/alias_new_index"14. Modify the index alias ( delete first and then add )
curl -XPOST "http://192.168.99.1:9200/_aliases" -d' { "actions": [ { "remove": { "index": "test_index","alias": "alias_index" } }, { "add": { "index": "test_index","alias": "alias_new_index" } } ] }'15. Delete index aliases
method one:
curl -XPOST "http://192.168.99.1:9200/_aliases" -d' { "actions": [ { "remove": { "index": "test_index","alias": "alias_new_index" } } ] }'Method 2: (delete the alias that the index starts with test and the alias is alias_new_index)
curl -XDELETE "http://192.168.99.1:9200/test*/_aliases/alias_new_index"16. Query all aliases under the test_index index
curl -XGET "http://192.168.99.1:9200/test_index/_alias/*"17. The query alias alias_new_index is associated with those indexes
curl -XGET "http://192.168.99.1:9200/_alias/alias_new_index"