删除旧索引
DELETE 索引名
创建新索引
PUT 索引名
{
"settings": {
"index": {
"number_of_shards": "3",
"number_of_replicas": "0"
}
}
}
设置索引mapping
PUT 索引名/_doc/_mapping
{
"properties": {
"id": {
"type": "keyword"
},
"day": {
"type": "integer"
},
"count": {
"type": "double"
},
"level": {
"type": "integer"
}
}
这里要注意,如果是用http方式创建的话,mapping需要带s:mappings。如下:

设置别名
POST _aliases
{
"actions" : [{"add" : {"index" : "索引名" , "alias" : "别名"}}]
}
这篇博客介绍了如何使用Elasticsearch操作索引,包括DELETE命令删除旧索引,PUT命令创建新索引并配置索引设置,如分片数和副本数。接着详细展示了如何设置索引的mapping,包括各种字段类型如keyword、integer和double。此外,还提到了通过POST请求添加别名的操作。内容对于理解和操作Elasticsearch索引管理非常实用。
3176





