Skip to content

Commit ab578ce

Browse files
committed
Merge pull request #169 from benregn/patch-1
add an example of adding an A object to Search
2 parents edfdbc8 + 914a297 commit ab578ce

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

docs/search_dsl.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,24 @@ To nest aggregations, you can use the ``.bucket()`` and ``.metric()`` methods:
215215
To add aggregations to the ``Search`` object, use the ``.aggs`` property, which
216216
acts as a top-level aggregation:
217217
218+
.. code:: python
219+
220+
s = Search()
221+
a = A('terms', field='category')
222+
s.aggs.bucket('category_terms', a)
223+
s.to_dict()
224+
# {
225+
# 'aggs': {
226+
# 'category_terms': {
227+
# 'terms': {
228+
# 'field': 'category'
229+
# }
230+
# }
231+
# }
232+
# }
233+
234+
or
235+
218236
.. code:: python
219237
220238
s = Search()

0 commit comments

Comments
 (0)