我有一个csv文件,我尝试使用Logstash上传到ES。我的conf文件如下:
input {
file {
path => ["filename"]
start_position => "beginning"
}
}
filter {
csv {
columns => ["name1", "name2", "name3", ...]
separator => ","
}
}
filter {
mutate {
remove_field => ["name31", "name32", "name33"]
}
}
output {
stdout{
codec => rubydebug
}
elasticsearch {
action => "index"
host => "localhost"
index => "newindex"
template_overwrite => true
document_type => "newdoc"
template => "template.json"
}
}
我的模板文件如下所示:
{
"mappings": {
"newdoc": {
"properties": {
"name1": {
"type": "integer"
},
"name2": {
"type": "float"
},
"name3": {
"format": "dateOptionalTime",
"type": "date"
},
"name4": {
"index": "not_analyzed",
"type": "string"
},
....
}
}
},
"settings": {
"number_of_replicas": 0,
"number_of_shards": 1
},
"template": "newindex"
}
当我尝试覆盖默认映射时,即使我只尝试写一行,也会出现400错误:
failed action with response of 400, dropping action: ["index", + ...
可能是什么问题?如果我不覆盖映射,一切正常,但这对我来说不是解决方案。我在Red Hat上使用Logstash 1.5.1和Elasticsearch 1.5.0。
由于
答案 0 :(得分:0)
在将数据加载到elasticsearch
之前,您应该将请求'mapping'发布到elasticsearch答案 1 :(得分:0)
在运行logstash之前不需要创建索引,如果还没有,它会创建索引,但最好在使用logstash运行conf文件之前创建自己的映射。让您更好地控制字段类型等。这是一个简单的教程,介绍如何使用logstash将csv导入elasticsearch:http://freefilesdl.com/how-to-connect-logstash-to-elasticsearch-output