创建索引
PUT aikaifa
索引创建成功后提示
{
"acknowledged" : true,
"shards_acknowledged" : true,
"index" : "aikaifa"
}
默认情况下,创建的索引分片数量是 3 个,副本数量是 1 个。
我们可以通过如下参数来指定分片数、副本数量:
PUT aikaifa{
"settings": {
"number_of_shards": 6,
"number_of_replicas": 2
}
}
索引创建成功后返回
{
"acknowledged": true,
"shards_acknowledged": true,
"index": "aikaifa"
}
纸上得来终觉浅,绝知此事要躬行
我们在kibana上做一次演示
如图所示
修改索引副本个数
PUT item_20210528/_settings{
"number_of_replicas": 3
}
返回结果:
{
"acknowledged" : true
}
如下图:
我们可以在创建索引的时候,同时将索引的类型、以及映射一并创建好:
PUT item_20210528{
{
"settings": {
"number_of_shards": 3,
"number_of_replicas": 1
},
"mappings": {
"properties": {
"user_id": {
"type": "long"
},
"user_name": {
"type": "text"
},
"user_address": {
"type": "keyword"
}
}
}
}
返回结果
{
"acknowledged": true,
"shards_acknowledged": true,
"index": "user_tt"
}
https://mp.weixin.qq.com/s/JhJjbKz6wahtMr2gep_Djg