kopia lustrzana https://github.com/wagtail/wagtail
len(ESResults) now runs query and gets the length of the results. Added ESResults.count() which asks Elasticsearch for the count but doesn't run the query
rodzic
16b385da97
commit
1475d440e3
|
@ -173,7 +173,7 @@ class ElasticSearchResults(object):
|
||||||
# Return results in order given by ElasticSearch
|
# Return results in order given by ElasticSearch
|
||||||
return [results[str(pk)] for pk in pks if results[str(pk)]]
|
return [results[str(pk)] for pk in pks if results[str(pk)]]
|
||||||
|
|
||||||
def _do_count(self):
|
def count(self):
|
||||||
# Get query
|
# Get query
|
||||||
query = self.query.to_es()
|
query = self.query.to_es()
|
||||||
|
|
||||||
|
@ -219,7 +219,7 @@ class ElasticSearchResults(object):
|
||||||
return iter(self._do_search())
|
return iter(self._do_search())
|
||||||
|
|
||||||
def __len__(self):
|
def __len__(self):
|
||||||
return self._do_count()
|
return len(self._do_search())
|
||||||
|
|
||||||
|
|
||||||
class ElasticSearch(BaseSearch):
|
class ElasticSearch(BaseSearch):
|
||||||
|
|
Ładowanie…
Reference in New Issue