Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[elk] Handle OpenSearch page info on pagination #1167

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions grimoire_elk/elk.py
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,9 @@ def get_uuids_in_index(target_uuids):
)

hits = []
if page['hits']['total'] != 0:
total = page['hits']['total']
total_value = total['value'] if isinstance(total, dict) else total
if total_value != 0:
hits = page['hits']['hits']

return hits
Expand Down Expand Up @@ -810,7 +812,8 @@ def delete_inactive_unique_identities(es, sortinghat_db, before_date):
)

sid = page['_scroll_id']
scroll_size = page['hits']['total']
total = page['hits']['total']
scroll_size = total['value'] if isinstance(total, dict) else total

if scroll_size == 0:
logging.warning("[identities retention] No inactive identities found in {} after {}!".format(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
title: Handle OpenSearch page info on pagination
category: fixed
author: Quan Zhou <[email protected]>
issue: null
notes: >
In OpenSearch and ElasticSearch < 7.x the page info on
pagination is different. This will handle both of them.