# Problems with GeoPoint field after switching to Elasticsearch Java API Client

**URL:** <https://discuss.elastic.co/t/problems-with-geopoint-field-after-switching-to-elasticsearch-java-api-client/342739>\
**Category:** Elasticsearch\
**Tags:** language-clients\
**Created:** [September 11, 2023, 12:47pm UTC](https://discuss.elastic.co/t/problems-with-geopoint-field-after-switching-to-elasticsearch-java-api-client/342739 "2023-09-11T12:47:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![MonikaS](https://avatars.discourse-cdn.com/v4/letter/m/87869e/32.png) [@MonikaS](https://discuss.elastic.co/u/MonikaS)\
**Post date:** [September 11, 2023, 12:47pm UTC](https://discuss.elastic.co/t/problems-with-geopoint-field-after-switching-to-elasticsearch-java-api-client/342739/1 "2023-09-11T12:47:32Z")

</div>

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.

```auto
{
   "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.

```auto
{
   "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.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [September 11, 2023, 1:09pm UTC](https://discuss.elastic.co/t/problems-with-geopoint-field-after-switching-to-elasticsearch-java-api-client/342739/2 "2023-09-11T13:09:35Z")

</div>

Welcome!

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

Like:

> <https://github.com/dadoonet/injector/blob/main/src/main/java/fr/pilato/elasticsearch/injector/bean/GeoPoint.java>

---

<div class="post-metadata">

**Author:** ![MonikaS](https://avatars.discourse-cdn.com/v4/letter/m/87869e/32.png) [@MonikaS](https://discuss.elastic.co/u/MonikaS)\
**Post date:** [September 18, 2023, 10:15am UTC](https://discuss.elastic.co/t/problems-with-geopoint-field-after-switching-to-elasticsearch-java-api-client/342739/3 "2023-09-18T10:15:52Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [October 16, 2023, 10:16am UTC](https://discuss.elastic.co/t/problems-with-geopoint-field-after-switching-to-elasticsearch-java-api-client/342739/4 "2023-10-16T10:16:39Z")

</div>

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