diff --git a/elasticmock/fake_elasticsearch.py b/elasticmock/fake_elasticsearch.py index dd1e5aa..909f072 100644 --- a/elasticmock/fake_elasticsearch.py +++ b/elasticmock/fake_elasticsearch.py @@ -9,7 +9,6 @@ from elasticmock.utilities import get_random_id - PY3 = sys.version_info[0] == 3 if PY3: unicode = str @@ -182,6 +181,20 @@ def search(self, index=None, doc_type=None, body=None, params=None): hits.append(match) result['hits']['hits'] = hits + # build aggregations + if 'aggs' in body: + aggregations = {} + + for aggregation, definition in body['aggs'].items(): + aggregations[aggregation] = { + "doc_count_error_upper_bound": 0, + "sum_other_doc_count": 0, + "buckets": [] + } + + if aggregations: + result['aggregations'] = aggregations + return result @query_params('consistency', 'parent', 'refresh', 'replication', 'routing', diff --git a/setup.py b/setup.py index 9521b1f..ceb4b3e 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ setup( name='ElasticMock', version=__version__, - url='https://github.com/vrcmarcos/elasticmock', + url='https://github.com/snakeye/elasticmock', license='MIT', author='Marcos Cardoso', author_email='vrcmarcos@gmail.com', @@ -17,8 +17,8 @@ include_package_data=True, platforms='any', install_requires=[ - 'elasticsearch<=1.9.0', - 'mock<=1.0.1' + 'elasticsearch', + 'mock' ], classifiers=[ 'Environment :: Web Environment',