From feccbc0412bfc6fd42deac007699fe6bd0fcb1d2 Mon Sep 17 00:00:00 2001 From: nicolas-f <1382241+nicolas-f@users.noreply.github.com> Date: Tue, 25 Jun 2024 09:23:28 +0200 Subject: [PATCH] Use create operation in order to not update a document with the same _id (same data) and resolve issues with concurrent operation --- .../playbooks/files/scripts_elasticsearch/feed_rpi_data.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/services/ansible_openvpn/playbooks/files/scripts_elasticsearch/feed_rpi_data.py b/services/ansible_openvpn/playbooks/files/scripts_elasticsearch/feed_rpi_data.py index 813d9dc..62a21c0 100644 --- a/services/ansible_openvpn/playbooks/files/scripts_elasticsearch/feed_rpi_data.py +++ b/services/ansible_openvpn/playbooks/files/scripts_elasticsearch/feed_rpi_data.py @@ -89,6 +89,8 @@ def fetch_data(args): json_dict["_id"] = base64.b64encode( hashlib.sha256(line).digest()).decode( sys.getdefaultencoding()) + if "_op_type" not in json_dict: + json_dict["_op_type"] = "create" yield json_dict processed_documents += 1 except json.decoder.JSONDecodeError: