Merge "Fix elasticsearch & opensearch requests"
This commit is contained in:
@@ -78,6 +78,9 @@ class ElasticsearchClient(object):
|
||||
must.append({'term': {'type': filters['type']}})
|
||||
|
||||
if metric_types:
|
||||
if type(metric_types) is not list:
|
||||
metric_types = [metric_types]
|
||||
|
||||
must.append({"terms": {"type": metric_types}})
|
||||
|
||||
return must
|
||||
|
||||
@@ -78,6 +78,9 @@ class OpenSearchClient(object):
|
||||
must.append({'term': {'type': filters['type']}})
|
||||
|
||||
if metric_types:
|
||||
if type(metric_types) is not list:
|
||||
metric_types = [metric_types]
|
||||
|
||||
must.append({"terms": {"type": metric_types}})
|
||||
|
||||
return must
|
||||
|
||||
@@ -53,6 +53,13 @@ class TestElasticsearchClient(unittest.TestCase):
|
||||
[{'term': {'type': 'awesome'}}],
|
||||
)
|
||||
|
||||
def test_build_must_with_metric_type(self):
|
||||
types = 'awesome'
|
||||
self.assertEqual(
|
||||
self.client._build_must(None, None, types, None),
|
||||
[{'terms': {'type': ['awesome']}}],
|
||||
)
|
||||
|
||||
def test_build_must_with_metric_types(self):
|
||||
types = ['awesome', 'amazing']
|
||||
self.assertEqual(
|
||||
|
||||
@@ -53,6 +53,13 @@ class TestOpenSearchClient(unittest.TestCase):
|
||||
[{'term': {'type': 'awesome'}}],
|
||||
)
|
||||
|
||||
def test_build_must_with_metric_type(self):
|
||||
types = 'awesome'
|
||||
self.assertEqual(
|
||||
self.client._build_must(None, None, types, None),
|
||||
[{'terms': {'type': ['awesome']}}],
|
||||
)
|
||||
|
||||
def test_build_must_with_metric_types(self):
|
||||
types = ['awesome', 'amazing']
|
||||
self.assertEqual(
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
fixes:
|
||||
- |
|
||||
Fix request to Elasticsearch/OpenSearch that has potentially not the
|
||||
correct type.
|
||||
Reference in New Issue
Block a user