使用Shell创建Elasticsearch索引库order_index并设置2个分片
可以使用Elasticsearch的REST API来创建一个名为'order_index'的索引,并将其分片为2个分片。具体步骤如下:
- 打开终端,使用以下命令创建索引:
curl -XPUT 'http://localhost:9200/order_index/' -H 'Content-Type: application/json' -d'
{
"settings": {
"number_of_shards": 2
}
}
'
-
上述命令中,'number_of_shards'指定了分片数量,这里设置为2。可以根据实际需求修改该值。
-
如果索引创建成功,将会返回以下响应:
{"acknowledged":true,"shards_acknowledged":true,"index":"order_index"}
- 现在,可以使用以下命令来验证索引已经创建成功:
curl -XGET 'http://localhost:9200/_cat/indices?v'
- 这将列出所有的索引,包括新创建的'order_index'。如果看到以下输出,则表示索引创建成功:
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
yellow open order_index K6x8DvPKQfutdQf4T3B9kA 2 1 0 0 416b 416b
- 现在,可以开始向该索引添加文档了。
AI 优化版
原文地址:https://www.cveoy.top/t/topic/ofOd 著作权归作者所有。请勿转载和采集!