From 0f5626c41d1bc0473a99a1e647744700abb3d34f Mon Sep 17 00:00:00 2001 From: sunjiacheng Date: Wed, 29 Mar 2023 13:03:15 +0800 Subject: [PATCH] [migration] fix source filter dsl (#43) [migration] fix source filter dsl Co-authored-by: Kassian Sun --- plugin/migration/pipeline.go | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/plugin/migration/pipeline.go b/plugin/migration/pipeline.go index f275f50a..66e858a4 100644 --- a/plugin/migration/pipeline.go +++ b/plugin/migration/pipeline.go @@ -955,28 +955,21 @@ func (p *DispatcherProcessor) splitMajorMigrationTask(taskItem *task2.Task) erro if v, ok := index.RawFilter.(string); ok { source["query_string"] = v } else { - source["query_dsl"] = index.RawFilter + var must []interface{} + if index.RawFilter != nil { + must = append(must, index.RawFilter) + } if index.Source.DocType != "" { if index.Target.DocType != "" { source["type_rename"] = util.MapStr{ index.Source.DocType: index.Target.DocType, } } - must := []interface{}{ - util.MapStr{ - "terms": util.MapStr{ - "_type": []string{index.Source.DocType}, - }, + must = append(must, util.MapStr{ + "terms": util.MapStr{ + "_type": []string{index.Source.DocType}, }, - } - if index.RawFilter != nil { - must = append(must, index.RawFilter) - } - source["query_dsl"] = util.MapStr{ - "bool": util.MapStr{ - "must": must, - }, - } + }) } else { if esSourceClient.GetMajorVersion() >= 8 { source["type_rename"] = util.MapStr{ @@ -984,6 +977,11 @@ func (p *DispatcherProcessor) splitMajorMigrationTask(taskItem *task2.Task) erro } } } + source["query_dsl"] = util.MapStr{ + "bool": util.MapStr{ + "must": must, + }, + } } var targetMust []interface{} if index.RawFilter != nil {