當我創建餅圖時,我想用"Others"
替換myfield
(即等於""
)字段的所有空值。我怎麼能在Kibana做到這一點?如何用Elasticsearch中的「其他」替換所有空/空值?
如果在Kibana中無法做到,那我該如何使用Elasticsearch做到這一點。
UPDATE:
我執行該查詢,並沒有給我任何錯誤:
GET myindex/entry/_update_by_query
{
"query":{
"term": {
"myfield.keyword": {
"value": ""
}
}
},
"script":{
"inline": "ctx._source.myfield = 'Other'",
"lang": "painless"
}
}
我得到這樣的輸出:
{
"took": 5,
"timed_out": false,
"total": 0,
"updated": 0,
"deleted": 0,
"batches": 0,
"version_conflicts": 0,
"noops": 0,
"retries": {
"bulk": 0,
"search": 0
},
"throttled_millis": 0,
"requests_per_second": -1,
"throttled_until_millis": 0,
"failures": []
}
但是當我檢查的值,我再次獲得值""
,而不是Other
。
GET myindex/_search?
{
"size":0,
"aggs": {
"months": {
"terms" : {
"field": "myfield"
}
}
}
}
這是我的索引映射:
PUT /myindex
{
"mappings": {
"entry": {
"_all": {
"enabled": false
},
"properties": {
"Id": {
"type":"keyword"
},
"Country": {
"type":"keyword"
},
"myfield": {
"type":"keyword"
},
"Year": {
"type":"integer"
},
"Counter": {
"type":"integer"
}
}
}
}
}
謝謝。什麼是'ctx'和'_source'? – Dinosaurius
我得到'parse_exception':'reason「:」期望的[inline],[file]或[stored]字段之一,但沒有找到「 – Dinosaurius
您正在使用哪個ES版本? –