From 2c5899e3114ea46e576ad135bbc50034f3213965 Mon Sep 17 00:00:00 2001 From: Liu JiaXiang Date: Thu, 4 Aug 2022 15:13:23 +0800 Subject: [PATCH] update es optional docType='', support es 8.X --- stash/es/writer.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/stash/es/writer.go b/stash/es/writer.go index 266bbe5..a4a93d6 100644 --- a/stash/es/writer.go +++ b/stash/es/writer.go @@ -52,7 +52,11 @@ func (w *Writer) execute(vals []interface{}) { var bulk = w.client.Bulk() for _, val := range vals { pair := val.(valueWithIndex) - req := elastic.NewBulkIndexRequest().Index(pair.index).Type(w.docType).Doc(pair.val) + req := elastic.NewBulkIndexRequest().Index(pair.index) + if len(w.docType) > 0 { + req = req.Type(w.docType) + } + req = req.Doc(pair.val) bulk.Add(req) } resp, err := bulk.Do(context.Background())