Location dosen't convert to geo_point

as descriped here i ran this template :

  put _template/nyc 
 {
    "order":0,
   "index_patterns":"nyc",
  "mapping":{
   "_default":{
    "properties":{
    "location ":{
      "type":"geo_point"
    }
  }
   }
}
 }

then i ran my configuration file :

 input{
file{
	path=>"C:\Users\Ahmed\Desktop\311_Service_Requests_from_2015.csv"
            start_position=>"beginning"
             sincedb_path=>NUL
         }
 }
filter{
    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","Borough","X Coordinate (State Plane)","Y Coordinate (State Plane)","Park Facility Name","Park Borough","School Name","School Number","School Region","School Code","School Phone Number",	"School Address","School City","School State","School Zip","School Not Found","School or Citywide Complaint","Vehicle Type","Taxi Company Borough","Taxi Pick Up Location","Bridge Highway Name","Bridge Highway Direction","Road Ramp","Bridge Highway Segment","Garage Lot Name","Ferry Direction","Ferry Terminal Name","Latitude","Longitude","Location"]

       }
     mutate{
     convert=>["Latitude","float"]
	 convert=>["Longitude","float"]	
	 
 	 }	    
 	 mutate{
 	 rename=>["Latitude","location[lat]"]
 	 rename=>["Longitude","location[lon]"]
 	 }
    

    date{ 
    	match=>["Created Date","MM/dd/yyyy HH:mm:ss aa"]
    	target=>"Date"
    	
    	}
  }

 output{	
    elasticsearch {
     hosts=> "localhost"
     index=> "nyc"
     document_type=>"calls"
    }        
  stdout{codec=>rubydebug}
} 

but i only get in the end location.lon and location.lan as float fields and not a geo_point location field as expecting.
so what im doing wrong ?

I do not know. However, it works if you use a dynamic template.

PUT _template/nyc 
{
  "order":0,
  "index_patterns":"nyc",
  "mappings": {
   "calls": {
      "dynamic_templates": [
        {
          "locations": {
            "match": "location",
            "mapping": { "type": "geo_point" }
          }
        }
      ]
    }
  }
}
1 Like

Thank you so much Badger, i was struggling with this for two days .

In case someone else lands upon this. If you do "GET _template/nyc" after putting that, you will find the template has no mappings. Three changes are required. "mapping" should be "mappings" and (as Magnus pointed out in the other thread) "location " needs that space to be removed. "_default" should be "_default_".

This works.

PUT _template/nyc 
 {
    "order":0,
    "index_patterns":"nyc",
    "mappings":{
      "_default_":{
        "properties":{
          "location":{
            "type":"geo_point"
          }
        }
      }
    }
 }
1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.