From 287d4c813259b5cae5b4dbcc9480fa3d82f48516 Mon Sep 17 00:00:00 2001 From: fmassot Date: Wed, 27 Mar 2024 21:53:23 +0100 Subject: [PATCH] Fix msearch with multi indexes. --- pkg/quickwit/client/client.go | 2 +- pkg/quickwit/client/client_test.go | 2 +- pkg/quickwit/client/models.go | 2 +- pkg/quickwit/client/search_request.go | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/quickwit/client/client.go b/pkg/quickwit/client/client.go index f24bce7..7c885ad 100644 --- a/pkg/quickwit/client/client.go +++ b/pkg/quickwit/client/client.go @@ -205,7 +205,7 @@ func (c *baseClientImpl) createMultiSearchRequests(searchRequests []*SearchReque mr := multiRequest{ header: map[string]interface{}{ "ignore_unavailable": true, - "index": c.index, + "index": strings.Split(c.index, ","), }, body: searchReq, interval: searchReq.Interval, diff --git a/pkg/quickwit/client/client_test.go b/pkg/quickwit/client/client_test.go index 6098864..ede4e29 100644 --- a/pkg/quickwit/client/client_test.go +++ b/pkg/quickwit/client/client_test.go @@ -93,7 +93,7 @@ func TestClient_ExecuteMultisearch(t *testing.T) { jBody, err := simplejson.NewJson(bodyBytes) require.NoError(t, err) - assert.Equal(t, "my-index", jHeader.Get("index").MustString()) + assert.Equal(t, "my-index", jHeader.Get("index").MustStringArray()[0]) assert.True(t, jHeader.Get("ignore_unavailable").MustBool(false)) assert.Empty(t, jHeader.Get("max_concurrent_shard_requests")) assert.False(t, jHeader.Get("ignore_throttled").MustBool()) diff --git a/pkg/quickwit/client/models.go b/pkg/quickwit/client/models.go index 6cfcbfc..6f0d105 100644 --- a/pkg/quickwit/client/models.go +++ b/pkg/quickwit/client/models.go @@ -8,7 +8,7 @@ import ( // SearchRequest represents a search request type SearchRequest struct { - Index string + Index []string Interval time.Duration Size int Sort []map[string]map[string]interface{} diff --git a/pkg/quickwit/client/search_request.go b/pkg/quickwit/client/search_request.go index 19e3328..c3a1d5a 100644 --- a/pkg/quickwit/client/search_request.go +++ b/pkg/quickwit/client/search_request.go @@ -37,7 +37,7 @@ func NewSearchRequestBuilder(interval time.Duration) *SearchRequestBuilder { // Build builds and return a search request func (b *SearchRequestBuilder) Build() (*SearchRequest, error) { sr := SearchRequest{ - Index: b.index, + Index: strings.Split(b.index, ","), Interval: b.interval, Size: b.size, Sort: b.sort,