From 4a145ee7cb9f523326c50614e33ba0577a2c92ac Mon Sep 17 00:00:00 2001 From: Simon Date: Sat, 18 Nov 2023 17:44:16 +0700 Subject: [PATCH] paginate to get total active docs count --- tubearchivist/home/src/index/reindex.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tubearchivist/home/src/index/reindex.py b/tubearchivist/home/src/index/reindex.py index 64b88132..53b62d13 100644 --- a/tubearchivist/home/src/index/reindex.py +++ b/tubearchivist/home/src/index/reindex.py @@ -105,11 +105,13 @@ class ReindexPopulate(ReindexBase): """get total hits from index""" index_name = reindex_config["index_name"] active_key = reindex_config["active_key"] - path = f"{index_name}/_search?filter_path=hits.total" - data = {"query": {"match": {active_key: True}}} - response, _ = ElasticWrap(path).post(data=data) - total_hits = response["hits"]["total"]["value"] - return total_hits + data = { + "query": {"term": {active_key: {"value": True}}}, + "_source": False, + } + total = IndexPaginate(index_name, data, keep_source=True).get_results() + + return len(total) def _get_daily_should(self, total_hits): """calc how many should reindex daily"""