def __len__(self): # if we pass a body without a query, elasticsearch complains if self._total: return self._total r = es_client.count(index=self.index, doc_type=self.doc_type, body=self.make_search_body() or None) self._total = r['count'] return self._total
def __len__(self): # if we pass a body without a query, elasticsearch complains if self._total: return self._total r = es_client.count( index=self.index, doc_type=self.doc_type, body=self.make_search_body() or None) self._total = r['count'] return self._total
def __len__(self): # if we pass a body without a query, elasticsearch complains if self._total: return self._total if self.mode == self.MODE_MLT: # Note: there is no count on the mlt api, need to fetch the results self.do_search() else: r = es_client.count(index=self.index, doc_type=self.doc_type, body=self.make_search_body() or None) self._total = r["count"] return self._total
def count(self): # if we pass a body without a query, elasticsearch complains if self._total: return self._total if self.mode == self.MODE_MLT: # Note: there is no count on the mlt api, need to fetch the results self.do_search() else: r = es_client.count(index=self.index, body=self.make_search_body() or None) self._total = r['count'] return self._total