[migration] fix source filter dsl (#43)

[migration] fix source filter dsl

Co-authored-by: Kassian Sun <kassiansun@outlook.com>
This commit is contained in:
sunjiacheng 2023-03-29 13:03:15 +08:00 committed by medcl
parent 08a1673c1a
commit 0f5626c41d
1 changed files with 13 additions and 15 deletions

View File

@ -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 {