logstash导入数据到elasticsearch时,报找到超过一个mapping type的解决办法

logstash导入数据到elasticsearch时,报Rejecting mapping update to [surveyuser] as the final mapping would have more than 1 type: [doc, surveyuser]的解决办法

trainuser 是索引名,impTrainUser是自定义的mapping名。

logstash版本6.3.2,ES版本6.3.2
在使用6。3。2版本的ES之前,已经使用5。5。2版本的ES跑通了,升级ES版本后,出现如题错误。
分析认为原因是logstash会默认给一个名字叫做doc的mapping type,而ES 6.x 开始不允许一个mapping下面有超过一个type,所以数据导不进去。
解决办法有两个:

1.在output里面指定document_type

例如
output {
if[type] == “impSurveyUser” {
elasticsearch {
hosts => [“10.16.2.236:9200”]
index => “surveyuser”
document_id => “%{surveyResultId}”
document_type => “surveyuser” //这里明确指定type,这个type就是自定义的
manage_template => true
template_overwrite => true
template_name => “surveyuser”
template => “/usr/local/logstash/logstash-6.3.2/templates/template_surveyuser.json”
}
}

stdout{
codec => json_lines
}
}

2.自定义的type名字取名叫doc

例如:
{
“template”: “surveyuser”,
“index_patterns”: “surveyuser”,
“order”: 2147483647,
“settings”: {
“index.number_of_shards”: 3,
“number_of_replicas”: 1,
“priority”: “900”,
“index.refresh_interval”: “10s”
},
“mappings”: {
“surveyuser”: {
“properties”: {
……
}
}
}
}
重新导入问题解决

猜你喜欢

转载自blog.csdn.net/momoudong/article/details/82017852
今日推荐