Merge remote-tracking branch 'origin/master'

This commit is contained in:
loveuer 2024-07-22 09:31:51 +08:00
commit beb2ca4cf4
3 changed files with 23 additions and 6 deletions

View File

@ -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"`

View File

@ -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 {

View File

@ -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