[英]In Elasticsearch, how to move data from one field into another field
I have an index with mappings that look like this: 我有一个带有映射的索引,如下所示:
"mappings": {
"default": {
"_all": {
"enabled": false
},
"properties": {
"Foo": {
"properties": {
"Bar": {
"type": "keyword"
}
}
}
}
}
I am trying to change the mapping to introduce a sub-field of Bar, called Code, whilst migrating the string currently in Bar into Bar.Code. 我试图更改映射以引入Bar的子字段(称为Code),同时将Bar中当前的字符串迁移到Bar.Code中。 Here is the new mapping:
这是新的映射:
"mappings": {
"default": {
"_all": {
"enabled": false
},
"properties": {
"Foo": {
"properties": {
"Bar": {
"properties": {
"Code": {
"type": "keyword"
}
}
}
}
}
}
}
In order to do this, I think I need to do a _reindex
and specify a pipeline. 为了做到这一点,我认为我需要做一个
_reindex
并指定一个管道。 Is that correct? 那是对的吗? If so, how does my pipeline access the original data?
如果是这样,我的管道如何访问原始数据?
I have tried variations on the following code, but without success: 我尝试了以下代码的变体,但没有成功:
PUT _ingest/pipeline/transformFooBar
{
"processors": [
{
"set": {
"field": "Bar.Code",
"value": "{{_source.Bar}}"
}
}
]
}
POST _reindex
{
"source": {
"index": "foo_v1"
},
"dest": {
"index": "foo_v2",
"pipeline": "transformFooBar"
}
}
Ah, I almost had the syntax right. 啊,我的语法几乎正确。 The _source is not required:
不需要_source:
// Create a pipeline with a SET processor
PUT _ingest/pipeline/transformFooBar
{
"processors": [
{
"set": {
"field": "Bar.Code",
"value": "{{Bar}}"
}
}
]
}
// Reindex using the above pipeline
POST _reindex
{
"source": {
"index": "foo_v1"
},
"dest": {
"index": "foo_v2",
"pipeline": "transformFooBar"
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.