Skip to content

Commit

Permalink
Corrige exclusão de scroll_id's não usados (#66)
Browse files Browse the repository at this point in the history
O Opensearch de produção ainda está dando erro de scroll_id's e foi
identificado que a paginação não estava os excluindo corretamente.
  • Loading branch information
Giulio Carvalho authored Dec 14, 2023
2 parents cc54af2 + 30325ce commit 033f94c
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions index/opensearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,13 @@ def paginated_search(
if len(result["hits"]["hits"]) == 0:
return

scroll_id = None
while len(result["hits"]["hits"]) > 0:
yield result

if scroll_id is not None and scroll_id != result["_scroll_id"]:
self._search_engine.clear_scroll(scroll_id=scroll_id)

scroll_id = result["_scroll_id"]
result = self._search_engine.scroll(
scroll_id=scroll_id, scroll=keep_alive, request_timeout=120
Expand Down

0 comments on commit 033f94c

Please sign in to comment.