Geo_point expected - Elasticsearch version 7.3.2

I'm trying to index a document with a valid "geo_point" data, but I got an error saying "geo_point expected". Can someone please advise?

Request:
curl -X PUT "10.80.0.78:9200/production-index/mytype/mydocument1?pretty" -H 'Content-Type: application/json' -d'{"account":"170/170/653","location":[-74.104158,41.053954]}'

Output:
{
"error" : {
"root_cause" : [
{
"type" : "parse_exception",
"reason" : "geo_point expected"
}
],
"type" : "mapper_parsing_exception",
"reason" : "failed to parse field [location] of type [geo_point]",
"caused_by" : {
"type" : "parse_exception",
"reason" : "geo_point expected"
}
},
"status" : 400
}

Can you try POST instead of PUT?

@Ignacio_Vera
I still receive the same error
curl -X POST "10.80.0.78:9200/production-listings/listings/mydocument1?pretty" -H 'Content-Type: application/json' -d'{"account":"170/170/653","location":[-74.104158,41.053954]}'

Unfortunately I cannot reproduce it, could you provide the mapping you are using?

@Ignacio_Vera
This is the mapping I'm using:
https://jsoneditoronline.org/?id=329a057fdd474c189f27f386317e9757

7.0+ must use the _doc type.... that is the issue I believe (Removal of types)

I just put in your mapping then posted the document, I think you have a leftover type listings in the URL

curl -X POST "localhost:9200/production-listings/_doc/mydocument1?pretty" -H 'Content-Type: application/json' -d'{"account":"170/170/653","location": [ -74.104158, 41.053954] }'

Oh an just for clarity sake POST with providing document id is not really correct ...

PUT with _id POST without so should be

curl -X POST "localhost:9200/production-listings/_doc?pretty" -H 'Content-Type: application/json' -d'{"account":"170/170/653","location": [ -74.104158, 41.053954] }'

or

curl -X PUT "localhost:9200/production-listings/_doc/mydocument1?pretty" -H 'Content-Type: application/json' -d'{"account":"170/170/653","location": [ -74.104158, 41.053954] }

Tested both worked

1 Like

Thank you @stephenb
It worked. I was not aware of removal of types
https://www.elastic.co/guide/en/elasticsearch/reference/current/removal-of-types.html

1 Like

you can validate your JSON data at https://jsonformatter.org

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