From d30233204f20a5a23028e2b662d4224ae4af13c8 Mon Sep 17 00:00:00 2001 From: caicandong <1290147055@qq.com> Date: Sun, 21 Jul 2024 13:27:08 +0800 Subject: [PATCH] bugfix --- model/es.go | 19 ++++++++++++++++++- xes/es6/read.go | 4 ++-- xes/es7/read.go | 6 +++--- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/model/es.go b/model/es.go index e81a780..97c4574 100644 --- a/model/es.go +++ b/model/es.go @@ -7,7 +7,24 @@ type ESSource struct { Sort []any `json:"sort"` } -type ESResponse struct { +type ESResponseV6 struct { + ScrollId string `json:"_scroll_id"` + Took int `json:"took"` + TimedOut bool `json:"timed_out"` + Shards struct { + Total int `json:"total"` + Successful int `json:"successful"` + Skipped int `json:"skipped"` + Failed int `json:"failed"` + } `json:"_shards"` + Hits struct { + Total int `json:"total"` + MaxScore float64 `json:"max_score"` + Hits []*ESSource `json:"hits"` + } `json:"hits"` +} + +type ESResponseV7 struct { ScrollId string `json:"_scroll_id"` Took int `json:"took"` TimedOut bool `json:"timed_out"` diff --git a/xes/es6/read.go b/xes/es6/read.go index fe1f809..4af13bd 100644 --- a/xes/es6/read.go +++ b/xes/es6/read.go @@ -24,7 +24,7 @@ func ReadData(ctx context.Context, client *elastic.Client, index string, size, m var ( err error resp *esapi.Response - result = new(model.ESResponse) + result = new(model.ESResponseV6) scrollId string total int ) @@ -121,7 +121,7 @@ func ReadData(ctx context.Context, client *elastic.Client, index string, size, m return } - result = new(model.ESResponse) + result = new(model.ESResponseV6) decoder = json.NewDecoder(resp.Body) if err = decoder.Decode(result); err != nil { diff --git a/xes/es7/read.go b/xes/es7/read.go index 53c6368..4a6f539 100644 --- a/xes/es7/read.go +++ b/xes/es7/read.go @@ -28,7 +28,7 @@ func ReadData(ctx context.Context, client *elastic.Client, index string, size, m var ( err error resp *esapi.Response - result = new(model.ESResponse) + result = new(model.ESResponseV7) scrollId string total int ) @@ -125,7 +125,7 @@ func ReadData(ctx context.Context, client *elastic.Client, index string, size, m return } - result = new(model.ESResponse) + result = new(model.ESResponseV7) decoder = json.NewDecoder(resp.Body) if err = decoder.Decode(result); err != nil { @@ -232,7 +232,7 @@ func ReadDataV2( return } - var result = new(model.ESResponse) + var result = new(model.ESResponseV7) decoder := json.NewDecoder(resp.Body) if err = decoder.Decode(result); err != nil { errCh <- err