kibana7 索引操作
2021-07-20 本文已影响0人
码农工号9527
切换到控制台 http://your_ip:5601/app/dev_tools#/console
1. 查看所有
GET _search
{
"query": {
"match_all": {}
}
}
结果
#! this request accesses system indices: [.apm-agent-configuration, .apm-custom-link, .async-search, .kibana_7.12.0_001, .kibana_task_manager_7.12.0_001, .tasks], but in a future major version, direct access to system indices will be prevented by default
{
"took" : 3,
"timed_out" : false,
"_shards" : {
"total" : 38,
"successful" : 38,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 10000,
"relation" : "gte"
},
"max_score" : 1.0,
"hits" : [
{
"_index" : ".async-search",
"_type" : "_doc",
"_id" : "Fgn8lVX1RX-T07u9-YDqMg",
"_score" : 1.0,
"_source" : {
"result" : "48myAwFIRmtabmJqaHNWbGd4VWxndFZEQTNkVGt0V1VSeFRXY2VXVEJQYmpkRmNtNVJlbWxuZVRObGJtVnNWbEJMZHpveE1qUTRORFUyAAEB9AUAf8AAAAAAAAABAQZsdGVybXMkNmI4OTM0NGItZTc5NC00NDBiLWEwMTgtM2VlZDk0NzQ0ZDEy//8CAQT/AgEEBQEABGJvb2wRAAAB9AUAAAAAAAAAAAAAAAIAAQEBAAAAAAAAAAAAAAAAAXqpYWJzAAABes1t5nM=",
"headers" : { },
"expiration_time" : 1626944169587,
"response_headers" : { }
}
},
......
2. 创建索引
指定分片数量和副分片数量来创建索引
PUT /test_index
{
"settings":{
"index":{
"number_of_shards" : "3",
"number_of_replicas" : "0"
}
}
}
结果:
{
"acknowledged" : true,
"shards_acknowledged" : true,
"index" : "test_index"
}
直接创建索引
PUT /test_index1
结果:
{
"acknowledged" : true,
"shards_acknowledged" : true,
"index" : "test_index1"
}
3. 查询索引
GET /test_index
结果:
{
"test_index" : {
"aliases" : { },
"mappings" : { },
"settings" : {
"index" : {
"routing" : {
"allocation" : {
"include" : {
"_tier_preference" : "data_content"
}
}
},
"number_of_shards" : "3",
"provided_name" : "test_index",
"creation_date" : "1626782384627",
"number_of_replicas" : "1",
"uuid" : "25Utmz-rQNOmAMjv3GxcsQ",
"version" : {
"created" : "7120099"
}
}
}
}
}
4. 修改索引副分片
PUT /test_index1/_settings
{
"number_of_replicas": 1
}
结果:
{
"acknowledged" : true
}
再次查询索引 GET /test_index
,结果为:
{
"test_index" : {
"aliases" : { },
"mappings" : { },
"settings" : {
"index" : {
"routing" : {
"allocation" : {
"include" : {
"_tier_preference" : "data_content"
}
}
},
"number_of_shards" : "3",
"provided_name" : "test_index",
"creation_date" : "1626782384627",
"number_of_replicas" : "2",
"uuid" : "25Utmz-rQNOmAMjv3GxcsQ",
"version" : {
"created" : "7120099"
}
}
}
}
}
number_of_replicas副分片变为2
5. 删除索引
#删除单个索引
DELETE /index_name
#一次性删除全部索引
DELETE /_all
DELETE /*