input {
file {
path => ["/root/opt/logstash-6.3.0/bin/logstash_csv/51n.csv"]
start_position => "beginning"
add_field => {"DATATYPE"=>"PT"}
add_field => {"LAYER"=>"51csv"}
}
}
filter {
csv {
separator => ","
columns => ["DZZYID","DZZYMC","DZ","YHFL","X","Y","LY","DHHM","FLDM","ZZJGDM","LX","GXSJ","FL"]
}
mutate {
convert => {
"DZZYID" => "string"
"DZZYMC" => "string"
"DZ" => "string"
"YHFL" => "string"
"X" => "string"
"Y" => "string"
"LY" => "string"
"DHHM" => "string"
"FLDM" => "string"
"ZZJGDM" => "string"
"LX" => "string"
"GXSJ" => "string"
"FL" => "string"
}
}
mutate{
add_field => {"LOCATION" => "%{Y},%{X}"}
}
mutate {
remove_field =>["message"]
remove_field =>["host"]
remove_field =>["@timestamp"]
remove_field =>["@version"]
remove_field =>["path"]
}
}
output {
elasticsearch {
hosts => ["172.25.16.154:9200", "172.25.16.147:9200", "172.25.16.148:9200"]
index => "51csv"
document_type => "doc"
template => "/root/opt/logstash-6.3.0/bin/logstash_csv/51csv.json"
manage_template => true
template_name => "51csv"
template_overwrite => true
}
}
51csv.json
{
"template": "51csv",
"mappings": {
"doc": {
"properties": {
"DZZYID": {
"type": "keyword"
},
"LAYER": {
"type": "keyword"
},
"DZZYMC": {
"type": "text",
"term_vector": "with_positions_offsets",
"analyzer": "ik_max_word"
},
"X": {
"type": "keyword"
},
"Y": {
"type": "keyword"
},
"LOCATION": {
"type": "geo_point"
},
"DATATYPE": {
"type": "keyword"
}
}
}
}
}