目錄
一、新增字段
二、修改字段值
三、批量修改字段值
?四、刪除字段
五、刪除數(shù)據(jù)/文檔
六、批量刪除數(shù)據(jù)/文檔
一、新增字段
put? ?http://{ip}:{port}/{index}/_mapping/{type}? ??其中,index是es索引、type是類型
數(shù)據(jù):
{
"_doc": {
"properties": {
"report_time": {
"type": "long"
}
}
}
}
例子:
注意:如果報(bào)錯(cuò)Types cannot be provided in put mapping requests, unless the include_type_name parameter is set to true
需要在url后面加上? ?include_type_name=true
二、修改字段值
post? ?http://{ip}:{port}/{index}/_update/{id}? ??其中,index是es索引、id是文檔_id
數(shù)據(jù):
{
"doc": {
"report_time": 1701315235000
}
}
樣例:
三、批量修改字段值
post? ?http://{ip}:{port}/{index}/_update_by_query? ??其中,index是es索引
數(shù)據(jù):把command_status字段等于1的數(shù)據(jù)的ip_address字段修改為2.2.2.2
{
"query": {
"match": {
"command_status": 1
}
},
"script": {
"inline": "ctx._source['ip_address'] = '2.2.2.2'"
}
}
如果需要修改索引里所有數(shù)據(jù),去掉query即可
{
"script": {
"inline": "ctx._source['ip_address'] = '2.2.2.2'"
}
}
四、刪除字段
post? ?http://{ip}:{port}/{index}/_update_by_query? ??其中,index是es索引
數(shù)據(jù): 刪除ip_address字段
{
"script": "ctx._source.remove('{ip_address}')",
"query": {
"bool": {
"must": [
{
"exists": {
"field": "ip_address"
}
}
]
}
}
}
五、刪除數(shù)據(jù)/文檔
delete? ?http://{ip}:{port}/{index}/{type}/{id}? ??其中,index是es索引、type是類型、id是文檔_id
數(shù)據(jù):無
六、批量刪除數(shù)據(jù)/文檔
post? ?http://{ip}:{port}/{index}/_delete_by_query? ?其中,index是es索引
數(shù)據(jù):刪除command_id等于1G7ZACL800908的數(shù)據(jù)或文檔文章來源:http://www.zghlxwxcb.cn/news/detail-762106.html
{
"query": {
"match": {
"command_id": "1G7ZACL800908"
}
}
}
文章來源地址http://www.zghlxwxcb.cn/news/detail-762106.html
到了這里,關(guān)于es head 新增字段、修改字段、批量修改字段、刪除字段、刪除數(shù)據(jù)、批量刪除數(shù)據(jù)的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!