Skip to content

Commit

Permalink
Merge pull request #169 from benregn/patch-1
Browse files Browse the repository at this point in the history
add an example of adding an A object to Search
  • Loading branch information
honzakral committed Jun 1, 2015
2 parents edfdbc8 + 914a297 commit ab578ce
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions docs/search_dsl.rst
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,24 @@ To nest aggregations, you can use the ``.bucket()`` and ``.metric()`` methods:
To add aggregations to the ``Search`` object, use the ``.aggs`` property, which
acts as a top-level aggregation:
.. code:: python
s = Search()
a = A('terms', field='category')
s.aggs.bucket('category_terms', a)
s.to_dict()
# {
# 'aggs': {
# 'category_terms': {
# 'terms': {
# 'field': 'category'
# }
# }
# }
# }
or
.. code:: python
s = Search()
Expand Down

0 comments on commit ab578ce

Please sign in to comment.