38 lines
891 B
Go
38 lines
891 B
Go
package model
|
|
|
|
import "encoding/json"
|
|
|
|
type ESDoc struct {
|
|
DocId string `json:"_id"`
|
|
Index string `json:"_index"`
|
|
Content map[string]any `json:"_source"`
|
|
}
|
|
|
|
func (d *ESDoc) ToMap() map[string]any {
|
|
return map[string]any{"_id": d.DocId, "_index": d.Index, "_source": d.Content}
|
|
}
|
|
|
|
func (d *ESDoc) Bytes() ([]byte, error) {
|
|
return json.Marshal(d)
|
|
}
|
|
|
|
type ESResponse 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 struct {
|
|
Value int `json:"value"`
|
|
Relation string `json:"relation"`
|
|
} `json:"total"`
|
|
MaxScore float64 `json:"max_score"`
|
|
Hits []*ESDoc `json:"hits"`
|
|
} `json:"hits"`
|
|
}
|