paginate to get total active docs count

This commit is contained in:
Simon 2023-11-18 17:44:16 +07:00
parent 463019ce5a
commit 4a145ee7cb
No known key found for this signature in database
GPG Key ID: 2C15AA5E89985DD4
1 changed files with 7 additions and 5 deletions

View File

@ -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"""