【发布时间】:2020-02-17 14:26:37
【问题描述】:
我一直在使用 Logstash 将一些索引从自托管 Elasticsearch 迁移到 AmazonElasticSearch。在迁移文档时,我们需要根据一些逻辑更改索引中的字段名称。
我们的 Logstash 配置文件
input {
elasticsearch {
hosts => ["https://staing-example.com:443"]
user => "userName"
password => "password"
index => "testingindex"
size => 100
scroll => "1m"
}
}
filter {
}
output {
amazon_es {
hosts => ["https://example.us-east-1.es.amazonaws.com:443"]
region => "us-east-1"
aws_access_key_id => "access_key_id"
aws_secret_access_key => "access_key_id"
index => "testingindex"
}
stdout{
codec => rubydebug
}
}
这是我们自托管弹性搜索中 testingIndex 的文档之一
{
"uniqueIdentifier" => "e32d331b-ce5f-45c8-beca-b729707fca48",
"createdDate" => 1527592562743,
"interactionInfo" => [
{
"value" => "Hello this is testing",
"title" => "msg",
"interactionInfoId" => "8c091cb9-e51b-42f2-acad-79ad1fe685d8"
},
{
**"value"** => """"{"edited":false,"imgSrc":"asdfadf/soruce","cont":"Collaborated in <b class=\"mention\" gid=\"4UIZjuFzMXiu2Ege6cF3R4q8dwaKb9pE\">@2222222</b> ","chatMessageObjStr":"Btester has quoted your feed","userLogin":"test.comal@google.co","userId":"tester123"}"""",
"title" => "msgMeta",
"interactionInfoId" => "f6c7203b-2bde-4cc9-a85e-08567f082af3"
}
],
"componentId" => "compId",
"status" => [
"delivered"
]
},
"accountId" => "test123",
"applicationId" => "appId"
}
当文档迁移到我们的 AmazonElasticSearch 时,这是我们所期望的
{
"uniqueIdentifier" => "e32d331b-ce5f-45c8-beca-b729707fca48",
"createdDate" => 1527592562743,
"interactionInfo" => [
{
"value" => "Hello this is testing",
"title" => "msg",
"interactionInfoId" => "8c091cb9-e51b-42f2-acad-79ad1fe685d8"
},
{
**"value-keyword"** => """"{"edited":false,"imgSrc":"asdfadf/soruce","cont":"Collaborated in <b class=\"mention\" gid=\"4UIZjuFzMXiu2Ege6cF3R4q8dwaKb9pE\">@2222222</b> ","chatMessageObjStr":"Btester has quoted your feed","userLogin":"test.comal@google.co","userId":"tester123"}"""",
"title" => "msgMeta",
"interactionInfoId" => "f6c7203b-2bde-4cc9-a85e-08567f082af3"
}
],
"componentId" => "compId",
"status" => [
"delivered"
]
},
"accountId" => "test123",
"applicationId" => "appId"
}
我们需要将 "value" 字段更改为 "value-keyword",只要我们找到一些 JSON 格式。 Logstash 中是否还有其他过滤器可以实现此目的
【问题讨论】:
-
你可以看看这些解决方案stackoverflow.com/questions/58538903/…
标签: elasticsearch logstash amazon-elasticsearch