ElasticSearch索引库的增删改查

官方文档:https://www.elastic.co/guide/en/elasticsearch/reference/6.8/indices.html

创建索引、设置分片

https://www.elastic.co/guide/en/elasticsearch/reference/6.8/indices-create-index.html

请求方式:PUT请求:

请求URL:
http://127.0.0.1:9200/<索引库名称>

设置分片(请求体添加如下数据):
{
   "settings" : {
      "number_of_shards" : 3,  # 主分片的数量,将数据分割成几部分
      "number_of_replicas" : 1   # 对于每一个主分片的数据,想要保存几个副本数据
   }  
}

**注意事项:**
1、索引的主分片一旦设置了就不允许修改了。
2、分片的副本数可以修改。

创建索引的时候可以同时创建Mapping类型映射,这个看官方文档吧。

查看索引信息

查看所有索引

https://www.elastic.co/guide/en/elasticsearch/reference/6.8/cat-indices.html

修改索引配置

没啥要改的,要改就看官方文档:

https://www.elastic.co/guide/en/elasticsearch/reference/6.8/indices-update-settings.html

删除索引

DELETE /索引名

DELETE http://127.0.0.1:9200/test

posted @ 2023-07-17 15:04  蕝戀  阅读(17)  评论(0编辑  收藏  举报