Merge "Fix API report requests when using opensearch" into stable/2023.2

This commit is contained in:
Zuul 2024-05-27 15:12:21 +00:00 committed by Gerrit Code Review
commit f720ad0577
3 changed files with 12 additions and 5 deletions

View File

@ -98,14 +98,15 @@ class OpenSearchClient(object):
sources = []
for elem in groupby:
if elem == 'type':
sources.append({'type': {'terms': {'field': 'type'}}})
sources.append({'type': {'terms': {'field': 'type.keyword'}}})
elif elem == 'time':
# Not doing a date_histogram aggregation because we don't know
# the period
sources.append({'begin': {'terms': {'field': 'start'}}})
sources.append({'end': {'terms': {'field': 'end'}}})
else:
sources.append({elem: {'terms': {'field': 'groupby.' + elem}}})
field = 'groupby.' + elem + '.keyword'
sources.append({elem: {'terms': {'field': field}}})
return {"sources": sources}

View File

@ -86,9 +86,9 @@ class TestOpenSearchClient(unittest.TestCase):
self.assertEqual(
self.client._build_composite(['one', 'type', 'two']),
{'sources': [
{'one': {'terms': {'field': 'groupby.one'}}},
{'type': {'terms': {'field': 'type'}}},
{'two': {'terms': {'field': 'groupby.two'}}},
{'one': {'terms': {'field': 'groupby.one.keyword'}}},
{'type': {'terms': {'field': 'type.keyword'}}},
{'two': {'terms': {'field': 'groupby.two.keyword'}}},
]},
)

View File

@ -0,0 +1,6 @@
---
fixes:
- |
Fix some API report requests that were returning HTTP 500 errors when using
the ``opensearch`` storage backend. This fixes failures to load the Horizon
``Rating`` panel.