Reputation: 612
I have an index in elasticsearch with a location field mapped as a geo_point. This is what's in the mappings tab of the index management settings.
{
"mappings": {
"_doc": {
"properties": {
"location": {
"type": "geo_point"
}
}
}
}
}
According to the geo-point docs on elasticsearch I should be able to send this in as a string of "lat,lon"
This is the value of a location in the json being sent to elastic
'location': '32.807078,-89.908972'
I'm getting this error message
RequestError(400, 'illegal_argument_exception', 'mapper [location] cannot be changed from type [geo_point] to [text]')
UPDATE
I was able to get data flowing in but now it's coming in as text data not geo_point!
This is in my index mapping along with the other mappings
This is in the data
Even though the mapping is there the data is text and I'm unable to use it in a map chart.
SOLUTION
Along with the checked answer, also needed to do this.
Go to Home -> Manage -> Kibana -> Index Patterns
Deleted the original index pattern and created a new one and now it's being seen as geo_data!
Upvotes: 1
Views: 11831
Reputation: 16172
On the basis of your index mapping, it seems that you are using the elasticsearch version that is before 7.x.
I have indexed a document using the same index mapping as provided in the question (using version 6.8). Don't forget to add _doc
(or the type you used in your index mapping) in the URL (when indexing the data)
Index Mapping:
{
"mappings": {
"_doc": {
"properties": {
"location": {
"type": "geo_point"
}
}
}
}
}
Index Data:
While posting a document to Elasticsearch, make sure the URL is in the format as mentioned below:
PUT my_index/_doc/1
{
"location": "41.12,-71.34"
}
Response:
{
"_index": "65076754",
"_type": "_doc",
"_id": "1",
"_version": 1,
"result": "created",
"_shards": {
"total": 2,
"successful": 1,
"failed": 0
},
"_seq_no": 0,
"_primary_term": 1
}
EDIT 1:
On the basis of comments below, the OP is using 7.x
Index Mapping using 7.x
{
"mappings": {
"properties": {
"location": {
"type": "geo_point"
}
}
}
}
Upvotes: 1