1
Elasticsearchで少数のドキュメントを更新しようとしています。マッピングタイプがlongであるいくつかのフィールドの値を更新したいとします。これらのフィールドの現在の値はnullです。Elasticsearchでドキュメントを更新中にエラーが発生しました
のPythonスクリプト:
def dump_random_values():
query = {"size": 2000, "query": {"bool": {"must": [{"term": {"trip_client_id": {"value": 23}}}, {"type": {"value": "trip-details"}}]}}}
docs = es.search(index=analytics_index, doc_type="trip-details", body=query)
trips = docs["hits"]["hits"]
for trip in trips:
doc_id = trip["_id"]
trip["_source"]["vehicle_capacityInWeight"] = random.randint(40, 50)
trip["_source"]["shipment_packageWeight"] = random.randint(1, 39)
trip["_source"]["vehicle_capacityInVolume"] = random.randint(40, 50)
trip["_source"]["shipment_packageVolume"] = random.randint(1, 39)
trip["_source"]["shipment_packageUnits"] = random.randint(40, 50)
trip = {"doc": trip}
es.update(index=analytics_index, doc_type="trip-details", id=doc_id, body=trip)
しかし、私はこのエラーを取得しています:私は
File "temp_updates.py", line 32, in <module>
dump_random_values()
File "temp_updates.py", line 30, in dump_random_values
es.update(index=analytics_index, doc_type="trip-details", id=doc_id, body=trip)
File "/Users/amanagarwal/Desktop/venv/analytics-django/lib/python3.5/site-packages/elasticsearch/client/utils.py", line 69, in _wrapped
return func(*args, params=params, **kwargs)
File "/Users/amanagarwal/Desktop/venv/analytics-django/lib/python3.5/site-packages/elasticsearch/client/__init__.py", line 460, in update
doc_type, id, '_update'), params=params, body=body)
File "/Users/amanagarwal/Desktop/venv/analytics-django/lib/python3.5/site-packages/elasticsearch/transport.py", line 329, in perform_request
status, headers, data = connection.perform_request(method, url, params, body, ignore=ignore, timeout=timeout)
File "/Users/amanagarwal/Desktop/venv/analytics-django/lib/python3.5/site-packages/elasticsearch/connection/http_urllib3.py", line 109, in perform_request
self._raise_error(response.status, raw_data)
File "/Users/amanagarwal/Desktop/venv/analytics-django/lib/python3.5/site-packages/elasticsearch/connection/base.py", line 108, in _raise_error
raise HTTP_EXCEPTIONS.get(status_code, TransportError)(status_code, error_message, additional_info)
elasticsearch.exceptions.RequestError: TransportError(400, 'mapper_parsing_exception', 'failed to parse')
何をしないのですか?