From 052bf37aca7f20b9c52077b5193cef4d52cc0f69 Mon Sep 17 00:00:00 2001 From: nagi49000 <48949843+nagi49000@users.noreply.github.com> Date: Tue, 13 Aug 2024 08:54:42 +0100 Subject: [PATCH] Allow read of data from elastic in later versions (#505) --- python/elastic_search_serialization.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/python/elastic_search_serialization.py b/python/elastic_search_serialization.py index bedad2dec..7b8294d9c 100644 --- a/python/elastic_search_serialization.py +++ b/python/elastic_search_serialization.py @@ -570,8 +570,9 @@ def scan( ) items = [] for item in response: - item[ID] = item[_SOURCE][INDEX][ID] - item[_SOURCE].pop(INDEX, None) + if _SOURCE in item and INDEX in item[_SOURCE]: + item[ID] = item[_SOURCE][INDEX][ID] + item[_SOURCE].pop(INDEX, None) items.append(item) return mgp.Record(items=items) @@ -608,8 +609,9 @@ def search( ) hits = [] for hit in response[HITS][HITS]: - hit[ID] = hit[_SOURCE][INDEX][ID] - hit[_SOURCE].pop(INDEX, None) + if _SOURCE in hit and INDEX in hit[_SOURCE]: + hit[ID] = hit[_SOURCE][INDEX][ID] + hit[_SOURCE].pop(INDEX, None) hits.append(hit) result = {}