So due to the fact that the issue with the Elasticsearch support has been hanging since 2022, I've been trying to implement async ElasticSearch integration myself using async_paginator.paginate function.
It's kind of hacky, but can be done by creating a wrapper function:
The thing is that in the current implementation the length_function is sync, and there is no way to make a call of a new_search.count() coroutine inside it, because it's currently in the running loop. So the only solution I came up with is calling count() before paginate, and passing the result in a lambda function, but it's too much hacky, not to mention that it will be called even if raw_params.include_total = False. So having an opportunity to use async length_function would be very nice.
So due to the fact that the issue with the Elasticsearch support has been hanging since 2022, I've been trying to implement async ElasticSearch integration myself using
async_paginator.paginate
function. It's kind of hacky, but can be done by creating a wrapper function:The thing is that in the current implementation the
length_function
is sync, and there is no way to make a call of anew_search.count()
coroutine inside it, because it's currently in the running loop. So the only solution I came up with is callingcount()
beforepaginate
, and passing the result in a lambda function, but it's too much hacky, not to mention that it will be called even ifraw_params.include_total = False
. So having an opportunity to use async length_function would be very nice.