diff options
Diffstat (limited to 'fuzzycat/utils.py')
-rw-r--r-- | fuzzycat/utils.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/fuzzycat/utils.py b/fuzzycat/utils.py index 24e103a..dadfa5c 100644 --- a/fuzzycat/utils.py +++ b/fuzzycat/utils.py @@ -30,6 +30,13 @@ def es_compat_hits_total(resp): """ try: return resp["hits"]["total"]["value"] # ES7 + except KeyError: + # with track_total_hits set to False, we observed missing "total" keys, + # es returns: {'_shards': {'failed': 0, 'skipped': 0, 'successful': 6, + # 'total': 6}, 'hits': {'hits': [{'_id': 'yvqtz2zvkzcbpj4jxrp7b...ons': + # [], 'any_abstract': False, 'ark_id': None, ...}, ...}], + # 'max_score': 108.32384}, 'timed_out': False, 'took': 921} + return len(resp["hits"]["hits"]) except TypeError: return resp["hits"]["total"] # ES6 |