I'm trying to pull in UK Crime data to Elasticsearch so that I can experiment with the map visualizations in Kibana 4. When I create a mapping to show that the location field is a geo_point, I then get errors when trying to import data.
Here are the steps to reproduce:
Create an empty index to receive crime data:
curl -XPUT 'http://localhost:9200/crime' -d '
index :
number_of_shards : 1
number_of_replicas : 1
'
Create a mapping to show that the json data already has a location field which gives latitude and longitude:
curl -XPUT 'http://localhost:9200/crime/_mapping/crimestats' -d '
{
"crimestats" : {
"properties" : {
"location" : {"type" : "geo_point"}
}
}
}
'
Using data from https://data.gov.uk/dataset/england-national-crime-mapping, paste a single line of JSON using the stdin input plugin. Get an error from Elasticsearch.
/opt/logstash/bin/logstash -e '
input {
stdin {
type => "crimestats"
codec => "json_lines"
}
}
output {
elasticsearch {
index => "crime"
host => "127.0.0.1"
protocol => "http"
manage_template => "false"
}
stdout {
codec => "rubydebug"
}
}
'
[2015-11-04 16:39:30.927] WARN -- Concurrent: [DEPRECATED] Java 7 is deprecated, please use Java 8.
Java 7 support is only best effort, it may not work. It will be removed in next release (1.0).
Logstash startup completed
Paste the following:
{"category":"anti-social-behaviour","location_type":"Force","location":{"latitude":"52.634845","street":
Here's the error returned from Elasticsearch:
{"id":332249,"name":"On or near Queen Street"},"longitude":"-1.124838"},"context":"","outcome_status":null,"persistent_id":"","id":3350469,"location_subtype":"","month":"2011-08"}
failed action with response of 400, dropping action: ["index", {:_id=>nil, :_index=>"crime", :_type=>"crimestats", :_routing=>nil}, #<LogStash::Event:0x7ac5cba7 @metadata={"retry_count"=>0}, @accessors=#<LogStash::Util::Accessors:0x2218c2e5 @store={"category"=>"anti-social-behaviour", "location_type"=>"Force", "location"=>{"latitude"=>"52.634845", "street"=>{"id"=>332249, "name"=>"On or near Queen Street"}, "longitude"=>"-1.124838"}, "context"=>"", "outcome_status"=>nil, "persistent_id"=>"", "id"=>3350469, "location_subtype"=>"", "month"=>"2011-08", "@version"=>"1", "@timestamp"=>"2015-11-04T22:21:56.913Z", "type"=>"crimestats", "host"=>"uottvr17ctrl01"}, @lut={"type"=>[{"category"=>"anti-social-behaviour", "location_type"=>"Force", "location"=>{"latitude"=>"52.634845", "street"=>{"id"=>332249, "name"=>"On or near Queen Street"}, "longitude"=>"-1.124838"}, "context"=>"", "outcome_status"=>nil, "persistent_id"=>"", "id"=>3350469, "location_subtype"=>"", "month"=>"2011-08", "@version"=>"1", "@timestamp"=>"2015-11-04T22:21:56.913Z", "type"=>"crimestats", "host"=>"uottvr17ctrl01"}, "type"], "host"=>[{"category"=>"anti-social-behaviour", "location_type"=>"Force", "location"=>{"latitude"=>"52.634845", "street"=>{"id"=>332249, "name"=>"On or near Queen Street"}, "longitude"=>"-1.124838"}, "context"=>"", "outcome_status"=>nil, "persistent_id"=>"", "id"=>3350469, "location_subtype"=>"", "month"=>"2011-08", "@version"=>"1", "@timestamp"=>"2015-11-04T22:21:56.913Z", "type"=>"crimestats", "host"=>"uottvr17ctrl01"}, "host"]}>, @data={"category"=>"anti-social-behaviour", "location_type"=>"Force", "location"=>{"latitude"=>"52.634845", "street"=>{"id"=>332249, "name"=>"On or near Queen Street"}, "longitude"=>"-1.124838"}, "context"=>"", "outcome_status"=>nil, "persistent_id"=>"", "id"=>3350469, "location_subtype"=>"", "month"=>"2011-08", "@version"=>"1", "@timestamp"=>"2015-11-04T22:21:56.913Z", "type"=>"crimestats", "host"=>"uottvr17ctrl01"}, @metadata_accessors=#<LogStash::Util::Accessors:0x7ccb7779 @store={"retry_count"=>0}, @lut={}>, @cancelled=false>] {:level=>:warn}
And rubydebug output
{
"category" => "anti-social-behaviour",
"location_type" => "Force",
"location" => {
"latitude" => "52.634845",
"street" => {
"id" => 332249,
"name" => "On or near Queen Street"
},
"longitude" => "-1.124838"
},
"context" => "",
"outcome_status" => nil,
"persistent_id" => "",
"id" => 3350469,
"location_subtype" => "",
"month" => "2011-08",
"@version" => "1",
"@timestamp" => "2015-11-04T22:21:56.913Z",
"type" => "crimestats",
"host" => "uottvr17ctrl01"
}
Note: no error if the index was created without a mapping.
Versions I'm using:
rpm -q elasticsearch kibana logstash
elasticsearch-1.7.1-1.noarch
kibana-4.1.1-1.x86_64
logstash-1.5.4-1.noarch