kibana Dev Tools中修改、新增數(shù)據(jù)示例kibana Dev Tools增刪改查基礎(chǔ)知識(shí):https://www.cnblogs.com/bigfacecat-h/p/14490917.html
目錄: 1、POST請(qǐng)求的特點(diǎn) 2、PUT請(qǐng)求的特點(diǎn) 3、使用_update_by_query 修改某個(gè)字段 4、使用_update修改某個(gè)字段
kibana Dev Tools中新增、修改數(shù)據(jù)可以使用POST、PUT請(qǐng)求,但兩者有區(qū)別 1、創(chuàng)建/修改索引時(shí),POST命令不需要指定文檔id(可以指定也可以不指定) POST不指定文檔id時(shí):是在同樣的索引下新增了一條數(shù)據(jù)(冪等操作) POST指定了文檔id時(shí):若該文檔id不存在,則創(chuàng)建索引;若文檔id已存在,則執(zhí)行更新操作(若新提交的字段不存在則增加該字段,若該字段已存在則更新該字段的值,其他字段值則刪掉)
2、創(chuàng)建/修改索引時(shí),PUT必須指定文檔id 若文檔id不存在,則創(chuàng)建索引 若文檔id已存在,則執(zhí)行更新操作(將請(qǐng)求中的整個(gè)json值完全替換掉舊的值)
3、通過(guò)查詢條件來(lái)限定修改范圍的方式修改某字段的值 update xxx.yyy.topic set result='[{\"aWord\":\"1哈哈哈哈\",\"count\":1,\"locations\":[\"00:05-00:08\",\"01:01-01:02\"]}]' where update_time >= 1591200000000 and update_time <= 1591362000000 POST xxx.yyy.topic/logs/_update_by_query { "query": { "bool": { "must": [ { "range": { "update_time": { "gte": 1591200000000, "lte": 1591362000000 } } } ] } }, "script": { "source": "ctx._source['result']='[{\"aWord\":\"1哈哈哈哈\",\"count\":1,\"locations\":[\"00:05-00:08\",\"01:01-01:02\"]}]'" } } json串中帶有特殊字符",需要用\進(jìn)行轉(zhuǎn)義 gte --表示大于等于 lte --表示小于等于
POST /index_bigfacecat_test/typeA/_update_by_query
{
"query":{
"bool":{
"must":[
{
"match":{
"name":"大臉貓2"
}
}
]
}
},
"script":{
"source":"ctx._source['name']='Big Face Cat2'"
}
}
POST /index_bigfacecat_test/typeA/_update { "script":"ctx._source.workdays+= 5" }
4、用主鍵作為條件來(lái)修改某個(gè)字段的值 update xxx.yyy.topic set result = '[{\"aWord\":\"1哈哈哈哈\",\"count\":1,\"locations\":[\"00:05-00:08\",\"01:01-01:02\"]}' where _id = 'xx-b2fc-43ca-afe7-77e3ff406ff9' POST xxx.yyy.topic/logs/xx-b2fc-43ca-afe7-77e3ff406ff9/_update { "doc":{ "result": """[{"aWord":"1哈哈哈哈","count":1,"locations":["00:05-00:08","01:01-01:02"]}]""" } } POST xxx.yyy.topic/logs/xx-b2fc-43ca-afe7-77e3ff406ff9/_update { "doc":{ "result": "哈哈哈" 注意:json中帶有特殊字符,需要兩個(gè)"""包起來(lái)
|
|
來(lái)自: 新進(jìn)小設(shè)計(jì) > 《待分類》