Creating Mapping in Elastic using CURL.
curl -XPUT "http://localhost:9200/_template/nyccalls" -H 'Content-Type: application/json' -d'
{
"order": 1,
"index_patterns": ["nyccalls*"],
"mappings":
{
"properties":
{
"Location":
{
"type": "geo_point"
},
"Created Date":
{
"type": "date",
"format": ["yyyy-MM-dd"T"HH:mm:ss.SSS"Z""]
}
}
}
}'
input {
file {
path => "/home/sidd/rows.csv"
start_position => "beginning"
sincedb_path => "/dev/null"
}
}
filter {
if[message] =~ /^#/ {
drop{}
}
csv {
separator =>","
columns => ["Unique Key","Created Date","Closed Date","Agency","Agency Name","Complaint Type","Descriptor","Location Type","Incident Zip","Incident Address","Street Name","Cross Street 1","Cross Street 2","Intersection Street 1","Intersection Street 2","Address Type","City","Landmark","Facility Type","Status","Due Date","Resolution Description","Resolution Action Updated Date","Community Board","BBL","Borough","X Coordinate (State Plane)","Y Coordinate (State Plane)","Open Data Channel Type","Park Facility Name","Park Borough","Vehicle Type","Taxi Company Borough","Taxi Pick Up Location","Bridge Highway Name","Bridge Highway Direction","Road Ramp","Bridge Highway Segment","Latitude","Longitude","Location"]
}
date {
match => ["Created Date", "MM/dd/yyyy hh:mm:ss a"]
target => "Created Date"
}
mutate {convert => ["X Coordinate (State Plane)","integer"]}
mutate {convert => ["Y Coordinate (State Plane)","integer"]}
mutate {convert => ["Latitude","float"]}
mutate {convert => ["Longitude","float"]}
mutate {replace => { "Location" => "%{Latitude},%{Longitude}" }}
if [Location] == "%{Latitude},%{Longitude}" {
mutate { remove_field => "Location" }
}
}
output {
elasticsearch {
hosts => "localhost"
index => "nyccalls"
}
#stdout {}
}