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:
Gábor Farkas 2023-07-11 09:47:16 +02:00 committed by GitHub
parent 1f83d64072
commit e17540bdcd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 8 deletions

View File

@ -207,7 +207,7 @@ func (c *baseClientImpl) createMultiSearchRequests(searchRequests []*SearchReque
header: map[string]interface{}{ header: map[string]interface{}{
"search_type": "query_then_fetch", "search_type": "query_then_fetch",
"ignore_unavailable": true, "ignore_unavailable": true,
"index": c.indices, "index": strings.Join(c.indices, ","),
}, },
body: searchReq, body: searchReq,
interval: searchReq.Interval, interval: searchReq.Interval,

View File

@ -96,7 +96,7 @@ func TestClient_ExecuteMultisearch(t *testing.T) {
jBody, err := simplejson.NewJson(bodyBytes) jBody, err := simplejson.NewJson(bodyBytes)
require.NoError(t, err) 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.True(t, jHeader.Get("ignore_unavailable").MustBool(false))
assert.Equal(t, "query_then_fetch", jHeader.Get("search_type").MustString()) assert.Equal(t, "query_then_fetch", jHeader.Get("search_type").MustString())
assert.Empty(t, jHeader.Get("max_concurrent_shard_requests")) assert.Empty(t, jHeader.Get("max_concurrent_shard_requests"))
@ -116,25 +116,25 @@ func TestClient_Index(t *testing.T) {
name string name string
indexInDatasource string indexInDatasource string
patternInDatasource string patternInDatasource string
indexInRequest []string indexInRequest string
}{ }{
{ {
name: "empty string", name: "empty string",
indexInDatasource: "", indexInDatasource: "",
patternInDatasource: "", patternInDatasource: "",
indexInRequest: []string{}, indexInRequest: "",
}, },
{ {
name: "single string", name: "single string",
indexInDatasource: "logs-*", indexInDatasource: "logs-*",
patternInDatasource: "", patternInDatasource: "",
indexInRequest: []string{"logs-*"}, indexInRequest: "logs-*",
}, },
{ {
name: "daily pattern", name: "daily pattern",
indexInDatasource: "[logs-]YYYY.MM.DD", indexInDatasource: "[logs-]YYYY.MM.DD",
patternInDatasource: "Daily", 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) jHeader, err := simplejson.NewJson(headerBytes)
require.NoError(t, err) require.NoError(t, err)
assert.Equal(t, test.indexInRequest, jHeader.Get("index").MustStringArray()) assert.Equal(t, test.indexInRequest, jHeader.Get("index").MustString())
}) })
} }
} }

View File

@ -82,7 +82,7 @@ func TestRequestSnapshots(t *testing.T) {
queryHeader := []byte(` queryHeader := []byte(`
{ {
"ignore_unavailable": true, "ignore_unavailable": true,
"index": ["testdb-2022.11.14"], "index": "testdb-2022.11.14",
"search_type": "query_then_fetch" "search_type": "query_then_fetch"
} }
`) `)