Tôi có tài liệu elasticsearch theo định dạng sau. Tôi cần phải cập nhật một phần "x" lĩnh vực và thêm một dict python trong nó.cập nhật một phần elasticsearch với python
{
"_index": "gdata34",
"_type": "gdat",
"_id": "328091-72341-118",
"_version": 1,
"_score": 1,
"_source": {
"d": {
"Thursday": {
"s": ""
},
"Email": {
"s": ""
},
"Country": {
"s": "US"
},
},
"x": {
"Geo": {
"s": "45.335428,-118.057133",
"g": [
-118.057133
,
45.335428
]
}
},
}
}
Tôi đã thử đoạn code sau để cập nhật:
from elasticsearch import Elasticsearch, exceptions
import pprint
elasticsearch = Elasticsearch()
doc = elasticsearch.get(index='gdata34', doc_type='gdat', id='328091-72341-7')
elasticsearch.update(index='gdata34', doc_type='gdat', id='328091-72341-7',
body={"script":"ctx._source.x += y",
"params":{"y":"z"}
}
)
elasticsearch.indices.refresh(index='gdata34')
new_doc = elasticsearch.get(index='gdata34', doc_type='gdat', id='328091-72341-7')
Tôi nhận được lỗi này:
elasticsearch.exceptions.RequestError: TransportError(400, u'ElasticsearchIllegalArgumentException[failed to execute script]; nested: ScriptException[dynamic scripting for [groovy] disabled]; ')
đúng cách để làm cập nhật từng phần trong elasticsearch sử dụng python là gì?
Bạn đang sử dụng phiên bản ES nào? –
@LukasGraf 1.4.4 – Anish