Skip to content

Commit

Permalink
Patch the elasticsearch backend too
Browse files Browse the repository at this point in the history
Required as this patch is still up for review:
https://review.opendev.org/c/openstack/kolla-ansible/+/898555

(cherry picked from commit 5888807)
  • Loading branch information
MoteHue authored and seunghun1ee committed Jul 1, 2024
1 parent 01a0057 commit 1853c37
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
5 changes: 3 additions & 2 deletions cloudkitty/storage/v2/elasticsearch/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,15 @@ def _build_composite(self, groupby):
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}

Expand Down
6 changes: 3 additions & 3 deletions cloudkitty/tests/storage/v2/elasticsearch/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ def test_build_composite(self):
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'}}},
]},
)

Expand Down

0 comments on commit 1853c37

Please sign in to comment.