mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Elasticsearch: Fix using multiple indexes with comma separated string (#71284)
* Revert "Elasticsearch: Use array of strings as index in backend queries (#67276)"
This reverts commit d0ced39847
.
* updated tests
This commit is contained in:
parent
1f83d64072
commit
e17540bdcd
@ -207,7 +207,7 @@ func (c *baseClientImpl) createMultiSearchRequests(searchRequests []*SearchReque
|
||||
header: map[string]interface{}{
|
||||
"search_type": "query_then_fetch",
|
||||
"ignore_unavailable": true,
|
||||
"index": c.indices,
|
||||
"index": strings.Join(c.indices, ","),
|
||||
},
|
||||
body: searchReq,
|
||||
interval: searchReq.Interval,
|
||||
|
@ -96,7 +96,7 @@ func TestClient_ExecuteMultisearch(t *testing.T) {
|
||||
jBody, err := simplejson.NewJson(bodyBytes)
|
||||
require.NoError(t, err)
|
||||
|
||||
assert.Equal(t, []string{"metrics-2018.05.15"}, jHeader.Get("index").MustStringArray())
|
||||
assert.Equal(t, "metrics-2018.05.15", jHeader.Get("index").MustString())
|
||||
assert.True(t, jHeader.Get("ignore_unavailable").MustBool(false))
|
||||
assert.Equal(t, "query_then_fetch", jHeader.Get("search_type").MustString())
|
||||
assert.Empty(t, jHeader.Get("max_concurrent_shard_requests"))
|
||||
@ -116,25 +116,25 @@ func TestClient_Index(t *testing.T) {
|
||||
name string
|
||||
indexInDatasource string
|
||||
patternInDatasource string
|
||||
indexInRequest []string
|
||||
indexInRequest string
|
||||
}{
|
||||
{
|
||||
name: "empty string",
|
||||
indexInDatasource: "",
|
||||
patternInDatasource: "",
|
||||
indexInRequest: []string{},
|
||||
indexInRequest: "",
|
||||
},
|
||||
{
|
||||
name: "single string",
|
||||
indexInDatasource: "logs-*",
|
||||
patternInDatasource: "",
|
||||
indexInRequest: []string{"logs-*"},
|
||||
indexInRequest: "logs-*",
|
||||
},
|
||||
{
|
||||
name: "daily pattern",
|
||||
indexInDatasource: "[logs-]YYYY.MM.DD",
|
||||
patternInDatasource: "Daily",
|
||||
indexInRequest: []string{"logs-2018.05.10", "logs-2018.05.11", "logs-2018.05.12"},
|
||||
indexInRequest: "logs-2018.05.10,logs-2018.05.11,logs-2018.05.12",
|
||||
},
|
||||
}
|
||||
|
||||
@ -210,7 +210,7 @@ func TestClient_Index(t *testing.T) {
|
||||
jHeader, err := simplejson.NewJson(headerBytes)
|
||||
require.NoError(t, err)
|
||||
|
||||
assert.Equal(t, test.indexInRequest, jHeader.Get("index").MustStringArray())
|
||||
assert.Equal(t, test.indexInRequest, jHeader.Get("index").MustString())
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ func TestRequestSnapshots(t *testing.T) {
|
||||
queryHeader := []byte(`
|
||||
{
|
||||
"ignore_unavailable": true,
|
||||
"index": ["testdb-2022.11.14"],
|
||||
"index": "testdb-2022.11.14",
|
||||
"search_type": "query_then_fetch"
|
||||
}
|
||||
`)
|
||||
|
Loading…
Reference in New Issue
Block a user