【es】关闭索引
部分索引在业务中不需要使用但是又不能将其直接删除,这时可以使用关闭索引的操作使得索引。索引被关闭后,该索引在集群中相关的内部数据也会被销毁,这有利于减少。如果想要使用时可以重新打开。
·
1.什么是关闭索引
部分索引在业务中不需要使用但是又不能将其直接删除,这时可以使用关闭索引的操作使得索引
不再接收读写请求。索引被关闭后,该索引在集群中相关的内部数据也会被销毁,这有利于减少
集群的负担。如果想要使用时可以重新打开。
2.关闭索引
curl -u elastic:elastic -k -XPOST "http://192.168.1.800:9200/test-3-2-1/_close"
{"acknowledged":true,"shards_acknowledged":true,"indices":{"test-3-2-1":{"closed":true}}}
curl -u elastic:elastic -k -XGET "http://192.168.1.800:9200/test-3-2-1"
{
"test-3-2-1":{
"aliases":{
},
"mappings":{
"properties":{
"born":{
"type":"date",
"format":"yyyy-MM-dd HH:mm:ss"
},
"id":{
"type":"integer"
},
"location":{
"type":"geo_point"
},
"name":{
"type":"text",
"fields":{
"keyword":{
"type":"keyword",
"ignore_above":256
}
}
},
"sex":{
"type":"boolean"
}
}
},
"settings":{
"index":{
"routing":{
"allocation":{
"include":{
"_tier_preference":"data_content"
}
}
},
"verified_before_close":"true", #表示索引已经关闭。
"number_of_shards":"1",
"provided_name":"test-3-2-1",
"creation_date":"1743409899031",
"number_of_replicas":"1",
"uuid":"umYMGGMtRuON1cpFBWY7OA",
"version":{
"created":"7170099"
}
}
}
}
}
--尝试写入已经关闭的索引
curl -u elastic:elastic -k -XPUT "http://192.168.1.800:9200/test-3-2-1/_doc/1" -H 'Content-Type: application/json' -d '
{
"visittime":"14:00:00",
"keywords":"[球会2]",
"rank":189,
"clicknum":133,
"id":10004,
"userid":"sdfsdfasdfa",
"key":"10004"
}'
{
"error":{
"root_cause":[
{
"type":"index_closed_exception",
"reason":"closed",
"index_uuid":"umYMGGMtRuON1cpFBWY7OA",
"index":"test-3-2-1"
}
],
"type":"index_closed_exception",
"reason":"closed",
"index_uuid":"umYMGGMtRuON1cpFBWY7OA",
"index":"test-3-2-1"
},
"status":400
}
3.打开索引并查看
curl -u elastic:elastic -k -XPOST "http://192.168.1.800:9200/test-3-2-1/_open"
{
"test-3-2-1":{
"aliases":{
},
"mappings":{
"properties":{
"born":{
"type":"date",
"format":"yyyy-MM-dd HH:mm:ss"
},
"id":{
"type":"integer"
},
"location":{
"type":"geo_point"
},
"name":{
"type":"text",
"fields":{
"keyword":{
"type":"keyword",
"ignore_above":256
}
}
},
"sex":{
"type":"boolean"
}
}
},
"settings":{
"index":{
"routing":{
"allocation":{
"include":{
"_tier_preference":"data_content"
}
}
}, #原先有这个参数:"verified_before_close":"true",索引打开后没有了。
"number_of_shards":"1",
"provided_name":"test-3-2-1",
"creation_date":"1743409899031",
"number_of_replicas":"1",
"uuid":"umYMGGMtRuON1cpFBWY7OA",
"version":{
"created":"7170099"
}
}
}
}
}
火山引擎开发者社区是火山引擎打造的AI技术生态平台,聚焦Agent与大模型开发,提供豆包系列模型(图像/视频/视觉)、智能分析与会话工具,并配套评测集、动手实验室及行业案例库。社区通过技术沙龙、挑战赛等活动促进开发者成长,新用户可领50万Tokens权益,助力构建智能应用。
更多推荐
所有评论(0)