我的“文档”请求:
temp_df_trimmed['RC'] = temp_df_trimmed['RC'].map(lambda x: np.nan if x=="?" else x)
我的“脚本”请求:
POST test_v2/_update/Z_nM_2wBjkGOA-r6ArOb
{
"doc": {
"CD": {
"middle": "prakash",
"first": "raj"
}
},
"doc_as_upsert": "true"
}
我想同时加入“脚本”和“文档”,并向他们提出一个请求,请帮助我实现这一目标。我正在使用ES v7.3。根据ES的说法,我不能将它们全部包含在一个请求中。
答案 0 :(得分:1)
ctx._source ['CD'] = params.object1 --->将更新或添加新字段
POST test3/_update/30RaAG0BY3127H1HaOEv
{
"scripted_upsert":true,
"script": {
"lang": "painless",
"inline": "ctx._source['CD']=params.object1; if(!ctx._source.containsKey('comments')){ctx._source['comments']=[]}ctx._source.comments.add(params.object)",
"params": {
"object": {
"model": "tata nano",
"value": "2"
},
"object1": {
"middle": "prakash1",
"first": "raj1"
}
}
},
"upsert" : {}
}