async def _scroll_documents(
        self,
        client: httpx.AsyncClient,
        initial_scroll_id: str,
    ) -> AsyncGenerator[List[Dict[str, Any]], None]:
        """Helper to scroll through documents using a scroll ID, yielding batches."""
        scroll_id = initial_scroll_id

        try:
            while True:
                scroll_data = {"scroll_id": scroll_id, "scroll": "1m"}
                data = await self._post(client, "/_search/scroll", scroll_data)
                hits = data.get("hits", {}).get("hits", [])
                if not hits:
                    break

                scroll_id = data["_scroll_id"]
                yield hits  # Yield a whole batch at once
        finally:
            # Always clean up scroll context
            if scroll_id:
                await client.delete("/_search/scroll", json={"scroll_id": [scroll_id]})
Helper to scroll through documents using a scroll ID, yielding batches.
backend/airweave/platform/sources/elasticsearch.py