Skip to content

Commit

Permalink
Merge pull request #602 from TeskaLabs/improvement/es-storage-service
Browse files Browse the repository at this point in the history
Fix ES storage service delete method
  • Loading branch information
Plesoun authored Aug 27, 2024
2 parents d476aa8 + 6755f72 commit dea4db4
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions asab/storage/elasticsearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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:
Expand Down

0 comments on commit dea4db4

Please sign in to comment.