Problems with GeoPoint field after switching to Elasticsearch Java API Client

Hi.

I'm trying to switch from RestHighLevelClient to Elasticsearch Java API Client in my Java application, and now it causes some problems with indexing geo_point fields. Specifically, I get.

{
   "index":{
      "_id":"id",
      "_index":"multiple_fields_entity",
      "status":400,
      "error":{
         "type":"mapper_parsing_exception",
         "reason":"failed to parse field [coordinates] of type [geo_point]",
         "caused_by":{
            "type":"parse_exception",
            "reason":"field must be either [lat], [lon] or [geohash]"
         }
      },
      "_type":"_doc"
   }
}

The version of Elasticsearch stayed the same, 7.17.11. The mapping of the multiple_fields_entity field is as follows.

{
   "dynamic":false,
   "properties":{
      ...,
      "coordinates":{
         "type":"geo_point"
      },
      ...
   }
}

When I send the document object in an index request, the coordinates field is of class org.elasticsearch.common.geo.GeoPoint. With the RestHighLevelClient everything worked fine; the error occurred after the client switch. Could you please help me to make it work? Thanks.

Welcome!

I think you should not depend on Elasticsearch GeoPoint class anymore but build your own with only the required fields.

Like:

Thanks, now I can index the object without a problem.

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