円グラフを作成するときに、フィールドmyfield
(すなわち、""
に等しい)の空の値をすべて"Others"
で置き換えたいとします。木場でどうすればいいですか?Elasticsearchで空白/空白の値を「その他」に置き換えるにはどうすればよいですか?
木場で行うことが不可能な場合は、どのようにして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バージョンはどれですか? –