Skip to content

Commit

Permalink
Merge pull request #4 from luiscastilho/result_total
Browse files Browse the repository at this point in the history
Check if result's hits.total field is an object or an int
  • Loading branch information
0mars authored Sep 15, 2020
2 parents e62cb51 + fe8bdd4 commit db2109d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/toute/bases/result.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ def delete(self, meta=None, **kwargs):
return eh.bulk(self._es, actions, **meta if meta else {})

def count(self):
return min(self._size, self.meta.get('hits', {}).get('total')['value'])
total = self.meta.get('hits', {}).get('total')
return min(self._size, total.get('value') if type(total) is dict else total)

def to_dict(self, *args, **kwargs):
"""
Expand Down

0 comments on commit db2109d

Please sign in to comment.