feat: es7 read data(scroll => search_after)
This commit is contained in:
@ -208,7 +208,11 @@ func executeData(ctx context.Context, input, output interfaces.DumpIO) error {
|
||||
log.Info("Query: got queries=%d", len(queries))
|
||||
|
||||
Loop:
|
||||
for _, query := range queries {
|
||||
for qi, query := range queries {
|
||||
bs, _ := json.Marshal(query)
|
||||
|
||||
log.Debug("Query[%d]: %s", qi, string(bs))
|
||||
|
||||
dch, ech = input.ReadData(ctx, f_limit, query, sources, []string{f_sort})
|
||||
|
||||
for {
|
||||
|
11
internal/util/min.go
Normal file
11
internal/util/min.go
Normal file
@ -0,0 +1,11 @@
|
||||
package util
|
||||
|
||||
import "cmp"
|
||||
|
||||
func Min[T cmp.Ordered](a, b T) T {
|
||||
if a <= b {
|
||||
return a
|
||||
}
|
||||
|
||||
return b
|
||||
}
|
@ -70,63 +70,8 @@ func (c *client) Close() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
//func (c *client) WriteData(ctx context.Context, docs []*model.ESSource) (int, error) {
|
||||
// var (
|
||||
// err error
|
||||
// indexer esutil.BulkIndexer
|
||||
// count int
|
||||
// be error
|
||||
// )
|
||||
// if indexer, err = esutil.NewBulkIndexer(esutil.BulkIndexerConfig{
|
||||
// Client: c.client,
|
||||
// Index: c.index,
|
||||
// ErrorTrace: true,
|
||||
// OnError: func(ctx context.Context, err error) {
|
||||
//
|
||||
// },
|
||||
// }); err != nil {
|
||||
// return 0, err
|
||||
// }
|
||||
//
|
||||
// for _, doc := range docs {
|
||||
// var bs []byte
|
||||
//
|
||||
// if bs, err = json.Marshal(doc.Content); err != nil {
|
||||
// return 0, err
|
||||
// }
|
||||
//
|
||||
// if err = indexer.Add(context.Background(), esutil.BulkIndexerItem{
|
||||
// Action: "index",
|
||||
// Index: c.index,
|
||||
// DocumentID: doc.DocId,
|
||||
// Body: bytes.NewReader(bs),
|
||||
// OnFailure: func(ctx context.Context, item esutil.BulkIndexerItem, item2 esutil.BulkIndexerResponseItem, bulkErr error) {
|
||||
// be = bulkErr
|
||||
// },
|
||||
// }); err != nil {
|
||||
// return 0, err
|
||||
// }
|
||||
// count++
|
||||
// }
|
||||
//
|
||||
// if err = indexer.Close(util.TimeoutCtx(ctx, opt.Timeout)); err != nil {
|
||||
// return 0, err
|
||||
// }
|
||||
//
|
||||
// if be != nil {
|
||||
// return 0, be
|
||||
// }
|
||||
//
|
||||
// stats := indexer.Stats()
|
||||
// if stats.NumFailed > 0 {
|
||||
// return count, fmt.Errorf("write to xes failed_count=%d bulk_count=%d", stats.NumFailed, count)
|
||||
// }
|
||||
//
|
||||
// return count, nil
|
||||
//}
|
||||
|
||||
func (c *client) ReadData(ctx context.Context, size int, query map[string]any, source []string, sort []string) (<-chan []*model.ESSource, <-chan error) {
|
||||
dch, ech := es7.ReadData(ctx, c.client, c.index, size, 0, query, source, sort)
|
||||
dch, ech := es7.ReadDataV2(ctx, c.client, c.index, size, 0, query, source, sort)
|
||||
|
||||
return dch, ech
|
||||
}
|
||||
|
Reference in New Issue
Block a user