Openverse is a search engine for openly-licensed media. This monorepo includes all application code.
Replace deprecated body in the ES requests with individual parameters (#3055)
ngken0995d7821c7117e6
diff --git a/api/api/controllers/search_controller.py b/api/api/controllers/search_controller.pyindex e90061c9b..4625989f6 100644--- a/api/api/controllers/search_controller.py+++ b/api/api/controllers/search_controller.py@@ -556,19 +556,17 @@ def get_sources(index):# Don't increase `size` without reading this issue first:# https://github.com/elastic/elasticsearch/issues/18838size = 100- agg_body = {- "aggs": {- "unique_sources": {- "terms": {- "field": "source.keyword",- "size": size,- "order": {"_key": "desc"},- }+ aggs = {+ "unique_sources": {+ "terms": {+ "field": "source.keyword",+ "size": size,+ "order": {"_key": "desc"},}}}try:- results = settings.ES.search(index=index, body=agg_body, request_cache=True)+ results = settings.ES.search(index=index, aggs=aggs, request_cache=True)buckets = results["aggregations"]["unique_sources"]["buckets"]except NotFoundError:buckets = [{"key": "none_found", "doc_count": 0}]