Skip to content
Snippets Groups Projects

Limit ES results count to 10000

Merged Erwan Rouchet requested to merge es-limit into master
1 file
+ 3
3
Compare changes
  • Side-by-side
  • Inline
@@ -34,7 +34,7 @@ class ESQuerySet(object):
index=self.es_index,
body={
"from": value.start,
"size": value.stop - value.start,
"size": min(value.stop - value.start, 10000), # The Scroll API is required to go over 10K results
"_source": self._source,
"query": self.query,
"aggs": self.aggs,
@@ -48,13 +48,13 @@ class ESQuerySet(object):
return self.count()
def count(self):
return self.elastic.count(
return min(self.elastic.count(
index=self.es_index,
body={
"query": self.query,
},
doc_type=self.es_type,
)['count']
)['count'], 10000) # The Scroll API is required to go over 10K results
def __iter__(self):
return self[0:len(self)]
Loading