擅长:python、mysql、java
<p>我也有同样的问题。我终于找到了解决办法:</p>
<pre><code>s = Search(using=client, index="jokes").query("match", jks_content=keywords).extra(size=0)
a = A('terms', field='jks_title.keyword', size=999999)
s.aggs.bucket('by_title', a)
response = s.execute()
</code></pre>
<p>在<code>2.x</code>之后,<code>size=0</code>对于所有的bucket结果将不再有效,请参考此<a href="https://stackoverflow.com/questions/22927098/show-all-elasticsearch-aggregation-results-buckets-and-not-just-10">thread</a>。在我的示例中,我将大小设置为999999。你可以根据你的情况选择一个大的数字。在</p>
<blockquote>
<p>It is recommended to explicitly set reasonable value for size a number
between 1 to 2147483647.</p>
</blockquote>
<p>希望这有帮助。在</p>