Skip to content

Commit f45727b

Browse files
authored
Merge pull request #79 from stackhpc/fix-opensearch-backend-yoga
Fix API report requests when using opensearch (yoga)
2 parents e74c23c + 7131ba5 commit f45727b

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

cloudkitty/storage/v2/elasticsearch/client.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,15 @@ def _build_composite(self, groupby):
9898
sources = []
9999
for elem in groupby:
100100
if elem == 'type':
101-
sources.append({'type': {'terms': {'field': 'type'}}})
101+
sources.append({'type': {'terms': {'field': 'type.keyword'}}})
102102
elif elem == 'time':
103103
# Not doing a date_histogram aggregation because we don't know
104104
# the period
105105
sources.append({'begin': {'terms': {'field': 'start'}}})
106106
sources.append({'end': {'terms': {'field': 'end'}}})
107107
else:
108-
sources.append({elem: {'terms': {'field': 'groupby.' + elem}}})
108+
field = 'groupby.' + elem + '.keyword'
109+
sources.append({elem: {'terms': {'field': field}}})
109110

110111
return {"sources": sources}
111112

cloudkitty/tests/storage/v2/elasticsearch/test_client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,9 @@ def test_build_composite(self):
8686
self.assertEqual(
8787
self.client._build_composite(['one', 'type', 'two']),
8888
{'sources': [
89-
{'one': {'terms': {'field': 'groupby.one'}}},
90-
{'type': {'terms': {'field': 'type'}}},
91-
{'two': {'terms': {'field': 'groupby.two'}}},
89+
{'one': {'terms': {'field': 'groupby.one.keyword'}}},
90+
{'type': {'terms': {'field': 'type.keyword'}}},
91+
{'two': {'terms': {'field': 'groupby.two.keyword'}}},
9292
]},
9393
)
9494

0 commit comments

Comments
 (0)