From 6755f724b557ea94e7fbcf56c38b3860056442c9 Mon Sep 17 00:00:00 2001 From: Jakub Schier Date: Mon, 26 Aug 2024 15:32:26 +0200 Subject: [PATCH] tweak delete method --- asab/storage/elasticsearch.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/asab/storage/elasticsearch.py b/asab/storage/elasticsearch.py index b586ba92f..119bffb52 100644 --- a/asab/storage/elasticsearch.py +++ b/asab/storage/elasticsearch.py @@ -215,7 +215,7 @@ async def delete(self, index: str, _id=None) -> dict: """ if _id: - path = "{}/_doc/{}?refresh={}".format(index, _id, self.Refresh) + path = "{}/_doc/{}?refresh={}".format(index, urllib.parse.quote_plus(_id), self.Refresh) else: path = "{}".format(index) @@ -224,9 +224,10 @@ async def delete(self, index: str, _id=None) -> dict: raise KeyError("No existing object with ID {}".format(_id)) elif resp.status not in {200, 201}: + resp = await resp.json() raise ConnectionError("Failed to retrieve data from ElasticSearch. Got {}: {}".format( resp.get("status"), - resp.get("error", {}).get("reason") + resp.get("error", {}) )) else: