ES的基本操作
1. 创建索引
说明:在这里面的mappings部分,可以从其他索引中进行拷贝过来,注意这个mappings中的info
是自定义的,有的用_docs
PUT /test12
{
"mappings" : {
"info" : {
"properties" : {
"@timestamp" : {
"type" : "date"
},
"@version" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"addtime" : {
"type" : "date",
"format" : "yyyy-MM-dd HH:mm:ss||yyyy/MM/dd HH:mm:ss||yyyy/MM/dd||epoch_millis"
},
"equ_id" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"path" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"pid" : {
"type" : "long"
}
}
}
}
}
2. 向索引中新增记录
说明:这里的info就是在创建索引中mappings下的那个属性值,如果那里是_docs,那这里就是_docs
POST /test12/info
{
"equ_id" : "34020000001320000892",
"path" : "https://pic-grd.obs.cn-south-1.myhuaweicloud.com:443/picture/20220627/34020000001320000892/192.168.1.64_01_20220627102232964_TIMING.jpg",
"addtime" : "2022-06-27 10:22:32",
"pid" : "18165922430487424"
}
3. 删除索引
DELETE /test12