feat: dump from es with query, limit

This commit is contained in:
loveuer
2024-03-23 21:25:19 +08:00
parent 983533237f
commit f1af294ced
16 changed files with 446 additions and 165 deletions

View File

@ -1,7 +1,10 @@
package interfaces
type DumpIO interface {
Write(docs []map[string]any) (int, error)
Read(int) ([]map[string]any, error)
Write(docs []*ESSource) (int, error)
Read(int) ([]*ESSource, error)
Close() error
IsInput() bool
IsFile() bool
}

View File

@ -0,0 +1,19 @@
package interfaces
type IO int64
const (
IOInput IO = iota
IOOutput
)
func (io IO) Code() string {
switch io {
case IOInput:
return "input"
case IOOutput:
return "output"
default:
return "unknown"
}
}

View File

@ -0,0 +1,27 @@
package interfaces
type ESSource struct {
DocId string `json:"_id"`
Index string `json:"_index"`
Content map[string]any `json:"_source"`
}
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 []*ESSource `json:"hits"`
} `json:"hits"`
}