如何通过logstash将数据从ES2.1迁移到ES7

发布于 2025-01-17 04:27:29 字数 11323 浏览 1 评论 0原文

[错误][logstash.outputs.elasticsearch][main]安装失败 template {:message=>"联系 Elasticsearch 时收到响应代码“400” 在 URL 'http://127.0.0.1:9200/_template/ecs-logstash'”, :Exception=>LogStash::Outputs::ElasticSearch::HttpClient::Pool::BadResponseCodeError

原始 ES 版本:2.1.2 新 ES 版本:7.13 Logstash 版本:8.1.1

我在 ES2 上有以下索引

"designs_v1": {
        "mappings": {
            "design": {
                "dynamic": "false",
                "_all": {
                    "enabled": false
                },
                "_id": {
                    "store": true,
                    "index": "not_analyzed"
                },
                "_timestamp": {
                    "enabled": true,
                    "store": true
                },
                "properties": {
                    "createDate": {
                        "type": "date",
                        "fielddata": {
                            "__comment": "Used for sorting",
                            "loading": "eager"
                        },
                        "format": "epoch_millis||date_time"
                    },
                    "designId": {
                        "type": "long",
                        "fielddata": {
                            "__comment": "Used for sorting to break ties and accessed by our custom scorer",
                            "loading": "eager"
                        }
                    },
                    "editorialTags": {
                        "type": "string",
                        "norms": {
                            "loading": "eager"
                        },
                        "analyzer": "standard_with_stopwords",
                        "fields": {
                            "shingles": {
                                "type": "string",
                                "norms": {
                                    "loading": "eager"
                                },
                                "analyzer": "shingle"
                            },
                            "stemmed": {
                                "type": "string",
                                "norms": {
                                    "loading": "eager"
                                },
                                "analyzer": "kstem"
                            }
                        }
                    },
                    "isPersonalizable": {
                        "type": "boolean"
                    },
                    "legalBlockTags": {
                        "type": "string",
                        "norms": {
                            "enabled": false
                        },
                        "analyzer": "standard_with_stopwords"
                    },
                    "memberId": {
                        "type": "long"
                    },
                    "pixel_height": {
                        "type": "integer"
                    },
                    "pixel_width": {
                        "type": "integer"
                    },
                    "products": {
                        "type": "nested",
                        "properties": {
                            "caption": {
                                "type": "string",
                                "norms": {
                                    "enabled": false
                                },
                                "analyzer": "standard_with_stopwords"
                            },
                            "createDate": {
                                "type": "date",
                                "format": "epoch_millis||date_time"
                            },
                            "defaultThumbnail": {
                                "type": "integer"
                            },
                            "description": {
                                "type": "string",
                                "norms": {
                                    "enabled": false
                                },
                                "analyzer": "standard_with_stopwords"
                            },
                            "hasPersonalizableSvg": {
                                "type": "boolean"
                            },
                            "imageOneId": {
                                "type": "long"
                            },
                            "imageTwoId": {
                                "type": "long"
                            },
                            "locations": {
                                "type": "string",
                                "norms": {
                                    "enabled": false
                                },
                                "analyzer": "keyword"
                            },
                            "productId": {
                                "type": "long"
                            },
                            "productTypeId": {
                                "type": "integer",
                                "fielddata": {
                                    "__comment": "Used during aggregations",
                                    "loading": "eager"
                                }
                            },
                            "showColorId": {
                                "type": "integer"
                            },
                            "storeId": {
                                "type": "long"
                            }
                        }
                    },
                    "sellerTags": {
                        "type": "string",
                        "norms": {
                            "loading": "eager"
                        },
                        "analyzer": "standard_with_stopwords",
                        "fields": {
                            "shingles": {
                                "type": "string",
                                "norms": {
                                    "loading": "eager"
                                },
                                "analyzer": "shingle"
                            },
                            "stemmed": {
                                "type": "string",
                                "norms": {
                                    "loading": "eager"
                                },
                                "analyzer": "kstem"
                            }
                        }
                    }
                }
            }
        }
    }

我创建了新索引在ES7中:

{
"mappings": {
        // "_id": {
        //     "store": true,
        //     "index": "not_analyzed"
        // },
        // "_timestamp": {
        //     "enabled": true,
        //     "store": true
        // },
        "properties": {
            "createDate": {
                "type": "date",
                "format": "epoch_millis||date_time"
            },
            "designId": {
                "type": "long"
            },
            "editorialTags": {
                "type": "text",
                "norms": true,
                "analyzer": "standard_with_stopwords",
                "fields": {
                    "shingles": {
                        "type": "text",
                        "norms": true,
                        "analyzer": "shingle"
                    },
                    "stemmed": {
                        "type": "text",
                        "norms": true,
                        "analyzer": "kstem"
                    }
                }
            },
            "isPersonalizable": {
                "type": "boolean"
            },
            "legalBlockTags": {
                "type": "text",
                "norms": false,
                "analyzer": "standard_with_stopwords"
            },
            "memberId": {
                "type": "long"
            },
            "pixel_height": {
                "type": "integer"
            },
            "pixel_width": {
                "type": "integer"
            },
            "products": {
                "type": "nested",
                "properties": {
                    "caption": {
                        "type": "text",
                        "norms": false,
                        "analyzer": "standard_with_stopwords"
                    },
                    "createDate": {
                        "type": "date",
                        "format": "epoch_millis||date_time"
                    },
                    "defaultThumbnail": {
                        "type": "integer"
                    },
                    "description": {
                        "type": "text",
                        "norms": false,
                        "analyzer": "standard_with_stopwords"
                    },
                    "hasPersonalizableSvg": {
                        "type": "boolean"
                    },
                    "imageOneId": {
                        "type": "long"
                    },
                    "imageTwoId": {
                        "type": "long"
                    },
                    "locations": {
                        "type": "text",
                        "norms": false,
                        "analyzer": "keyword"
                    },
                    "productId": {
                        "type": "long"
                    },
                    "productTypeId": {
                        "type": "integer"
                    },
                    "showColorId": {
                        "type": "integer"
                    },
                    "storeId": {
                        "type": "long"
                    }
                }
            },
            "sellerTags": {
                "type": "text",
                "norms": true,
                "analyzer": "standard_with_stopwords",
                "fields": {
                    "shingles": {
                        "type": "text",
                        "norms": true,
                        "analyzer": "shingle"
                    },
                    "stemmed": {
                        "type": "text",
                        "norms": true,
                        "analyzer": "kstem"
                    }
                }
            }
        }
    }
}

我想通过logstash将数据迁移到ES7,下面是我的logstash conf文件:

input {
  elasticsearch {
    hosts => ["http://xxx:9200"]
    index => "designs_v1"
    type => "design"
    size => 10
    scroll => "1m"
  }
}
filter {
}
output {
  elasticsearch {
    hosts => ["http://127.0.0.1:9200"]
    index => "designs_v1"
    #document_type => "%{[@metadata][_type]}"
    document_id => "%{[@metadata][_id]}"
  }
}

但我无法解决问题:

[错误][logstash.outputs.elasticsearch][main]安装失败 template {:message=>"联系 Elasticsearch 时收到响应代码“400” 在 URL 'http://127.0.0.1:9200/_template/ecs-logstash'”, :Exception=>LogStash::Outputs::ElasticSearch::HttpClient::Pool::BadResponseCodeError

我现在能做什么?

[ERROR][logstash.outputs.elasticsearch][main] Failed to install
template {:message=>"Got response code '400' contacting Elasticsearch
at URL 'http://127.0.0.1:9200/_template/ecs-logstash'",
:exception=>LogStash::Outputs::ElasticSearch::HttpClient::Pool::BadResponseCodeError

original ES version: 2.1.2 new ES version: 7.13 logstash version: 8.1.1

I have below index on my ES2

"designs_v1": {
        "mappings": {
            "design": {
                "dynamic": "false",
                "_all": {
                    "enabled": false
                },
                "_id": {
                    "store": true,
                    "index": "not_analyzed"
                },
                "_timestamp": {
                    "enabled": true,
                    "store": true
                },
                "properties": {
                    "createDate": {
                        "type": "date",
                        "fielddata": {
                            "__comment": "Used for sorting",
                            "loading": "eager"
                        },
                        "format": "epoch_millis||date_time"
                    },
                    "designId": {
                        "type": "long",
                        "fielddata": {
                            "__comment": "Used for sorting to break ties and accessed by our custom scorer",
                            "loading": "eager"
                        }
                    },
                    "editorialTags": {
                        "type": "string",
                        "norms": {
                            "loading": "eager"
                        },
                        "analyzer": "standard_with_stopwords",
                        "fields": {
                            "shingles": {
                                "type": "string",
                                "norms": {
                                    "loading": "eager"
                                },
                                "analyzer": "shingle"
                            },
                            "stemmed": {
                                "type": "string",
                                "norms": {
                                    "loading": "eager"
                                },
                                "analyzer": "kstem"
                            }
                        }
                    },
                    "isPersonalizable": {
                        "type": "boolean"
                    },
                    "legalBlockTags": {
                        "type": "string",
                        "norms": {
                            "enabled": false
                        },
                        "analyzer": "standard_with_stopwords"
                    },
                    "memberId": {
                        "type": "long"
                    },
                    "pixel_height": {
                        "type": "integer"
                    },
                    "pixel_width": {
                        "type": "integer"
                    },
                    "products": {
                        "type": "nested",
                        "properties": {
                            "caption": {
                                "type": "string",
                                "norms": {
                                    "enabled": false
                                },
                                "analyzer": "standard_with_stopwords"
                            },
                            "createDate": {
                                "type": "date",
                                "format": "epoch_millis||date_time"
                            },
                            "defaultThumbnail": {
                                "type": "integer"
                            },
                            "description": {
                                "type": "string",
                                "norms": {
                                    "enabled": false
                                },
                                "analyzer": "standard_with_stopwords"
                            },
                            "hasPersonalizableSvg": {
                                "type": "boolean"
                            },
                            "imageOneId": {
                                "type": "long"
                            },
                            "imageTwoId": {
                                "type": "long"
                            },
                            "locations": {
                                "type": "string",
                                "norms": {
                                    "enabled": false
                                },
                                "analyzer": "keyword"
                            },
                            "productId": {
                                "type": "long"
                            },
                            "productTypeId": {
                                "type": "integer",
                                "fielddata": {
                                    "__comment": "Used during aggregations",
                                    "loading": "eager"
                                }
                            },
                            "showColorId": {
                                "type": "integer"
                            },
                            "storeId": {
                                "type": "long"
                            }
                        }
                    },
                    "sellerTags": {
                        "type": "string",
                        "norms": {
                            "loading": "eager"
                        },
                        "analyzer": "standard_with_stopwords",
                        "fields": {
                            "shingles": {
                                "type": "string",
                                "norms": {
                                    "loading": "eager"
                                },
                                "analyzer": "shingle"
                            },
                            "stemmed": {
                                "type": "string",
                                "norms": {
                                    "loading": "eager"
                                },
                                "analyzer": "kstem"
                            }
                        }
                    }
                }
            }
        }
    }

I created new index in ES7:

{
"mappings": {
        // "_id": {
        //     "store": true,
        //     "index": "not_analyzed"
        // },
        // "_timestamp": {
        //     "enabled": true,
        //     "store": true
        // },
        "properties": {
            "createDate": {
                "type": "date",
                "format": "epoch_millis||date_time"
            },
            "designId": {
                "type": "long"
            },
            "editorialTags": {
                "type": "text",
                "norms": true,
                "analyzer": "standard_with_stopwords",
                "fields": {
                    "shingles": {
                        "type": "text",
                        "norms": true,
                        "analyzer": "shingle"
                    },
                    "stemmed": {
                        "type": "text",
                        "norms": true,
                        "analyzer": "kstem"
                    }
                }
            },
            "isPersonalizable": {
                "type": "boolean"
            },
            "legalBlockTags": {
                "type": "text",
                "norms": false,
                "analyzer": "standard_with_stopwords"
            },
            "memberId": {
                "type": "long"
            },
            "pixel_height": {
                "type": "integer"
            },
            "pixel_width": {
                "type": "integer"
            },
            "products": {
                "type": "nested",
                "properties": {
                    "caption": {
                        "type": "text",
                        "norms": false,
                        "analyzer": "standard_with_stopwords"
                    },
                    "createDate": {
                        "type": "date",
                        "format": "epoch_millis||date_time"
                    },
                    "defaultThumbnail": {
                        "type": "integer"
                    },
                    "description": {
                        "type": "text",
                        "norms": false,
                        "analyzer": "standard_with_stopwords"
                    },
                    "hasPersonalizableSvg": {
                        "type": "boolean"
                    },
                    "imageOneId": {
                        "type": "long"
                    },
                    "imageTwoId": {
                        "type": "long"
                    },
                    "locations": {
                        "type": "text",
                        "norms": false,
                        "analyzer": "keyword"
                    },
                    "productId": {
                        "type": "long"
                    },
                    "productTypeId": {
                        "type": "integer"
                    },
                    "showColorId": {
                        "type": "integer"
                    },
                    "storeId": {
                        "type": "long"
                    }
                }
            },
            "sellerTags": {
                "type": "text",
                "norms": true,
                "analyzer": "standard_with_stopwords",
                "fields": {
                    "shingles": {
                        "type": "text",
                        "norms": true,
                        "analyzer": "shingle"
                    },
                    "stemmed": {
                        "type": "text",
                        "norms": true,
                        "analyzer": "kstem"
                    }
                }
            }
        }
    }
}

I want to migrate data to ES7 by logstash, below is my logstash conf file:

input {
  elasticsearch {
    hosts => ["http://xxx:9200"]
    index => "designs_v1"
    type => "design"
    size => 10
    scroll => "1m"
  }
}
filter {
}
output {
  elasticsearch {
    hosts => ["http://127.0.0.1:9200"]
    index => "designs_v1"
    #document_type => "%{[@metadata][_type]}"
    document_id => "%{[@metadata][_id]}"
  }
}

But I can't fix issue:

[ERROR][logstash.outputs.elasticsearch][main] Failed to install
template {:message=>"Got response code '400' contacting Elasticsearch
at URL 'http://127.0.0.1:9200/_template/ecs-logstash'",
:exception=>LogStash::Outputs::ElasticSearch::HttpClient::Pool::BadResponseCodeError

What can I do now?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文