Skip to content

Commit

Permalink
Replace deprecated body in the ES requests with individual parameters (
Browse files Browse the repository at this point in the history
…#3055)

* change deprecated ES search body

* trim white space
  • Loading branch information
ngken0995 authored Sep 26, 2023
1 parent c8c10e2 commit d7821c7
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions api/api/controllers/search_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -556,19 +556,17 @@ def get_sources(index):
# Don't increase `size` without reading this issue first:
# https://github.com/elastic/elasticsearch/issues/18838
size = 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}]
Expand Down

0 comments on commit d7821c7

Please sign in to comment.