Hi,
When im writing longitude latitude values in string format with spark sql the data type of "location" field mapping to string not to geo_type
I followed the format
https://www.elastic.co/guide/en/elasticsearch/reference/current/geo-point.html
Query :sqlContext.sql( "SELECT vehicle_id,device_id,creation_time,timestamp_hour,engine_rpm ,concat( lon,lit(","),lat) as location FROM mytable" ) .saveToEs("iot_location/docs")
so that my string value from spark sql will be mapped to geo_type in elastic search
but its only mapping to string.
When i tried with array of longitude ,latitude elastic search mapping it to array
when i tried with structure (longitude ,latitude ) elastic search mapping to to structure
I need "location" to be geo_type so that i can use this field in kibana and grafana
location "41.12,-71.34" as string
location -71.34, 41.12 as an array
My index mappings
"index": {
"mappings": {
"sensorinfo": {
"properties": {
"creation_time": {
"format": "strict_date_optional_time||epoch_millis",
"type": "date"
},
"location": {
"type": "geo_point",
"lat_lon": "true"
},
"engine_rpm": {
"type": "float"
},
"timestamp_hour": {
"format": "strict_date_optional_time||epoch_millis",
"type": "date"
},
"device_id": {
"type": "string",
"analyzer": "analyzer-name"
},
"vehicle_id": {
"type": "string",
"analyzer": "analyzer-name"
}
}
}
},
**Changed mappings after writing data to elastic**
},
"mappings": {
"docs": {
"properties": {
"creation_time": {
"format": "strict_date_optional_time||epoch_millis",
"type": "date"
},
"timestamp_hour": {
"format": "strict_date_optional_time||epoch_millis",
"type": "date"
},
"device_id": {
"type": "string"
},
"location": {
"type": "string"
},
"engine_rpm": {
"type": "double"
},
"vehicle_id": {
"type": "string"
}
}
}
},
"aliases": [ ]
}