# I can not use geo\_point latitude longitude from my spring application

**URL:** <https://discuss.elastic.co/t/i-can-not-use-geo-point-latitude-longitude-from-my-spring-application/173995>\
**Category:** Elasticsearch\
**Created:** [March 26, 2019, 6:57pm UTC](https://discuss.elastic.co/t/i-can-not-use-geo-point-latitude-longitude-from-my-spring-application/173995 "2019-03-26T18:57:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ulpcan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ulpcan/32/120416_2.png) [@Ulpcan](https://discuss.elastic.co/u/Ulpcan)\
**Post date:** [March 26, 2019, 6:57pm UTC](https://discuss.elastic.co/t/i-can-not-use-geo-point-latitude-longitude-from-my-spring-application/173995/1 "2019-03-26T18:57:54Z")

</div>

I want to create index in ElasticSearch with configuration. I want to use geo distance query in elasticSearch

I have a java class and I am using GeoPoint object that ElasticSearch has and which is from: org.elasticsearch.common.geo.GeoPoint;

```auto
@Data
@EqualsAndHashCode(callSuper = false)
public class GeofenceDocument extends AbstractBaseDocument {

    @Id
    private String id;
    private Double radius;
    private GeoPoint location;
    private String geofenceName;
    private Set<String> pushIds;

}

```

I am inserting this class exactly as it is using my java IndexRequest. I am looking from kibana and see my location result as

```auto
      "location": {
        "properties": {
          "geohash": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "lat": {
            "type": "float"
          },
          "lon": {
            "type": "float"
          }
        }
      },

```

I dont want "type" : "keyword", I want "type" : "geo\_point" so ElasticSearch can query within given latitude and longitude.

I don't want this because, in order to use geo query I need to configure like this:

In below configure, I did it manually from kibana

```auto
PUT myindex
{
    "mappings": {
        "_doc": {
            "properties": {
                "location": {
                "type": "geo_point"
                        }
                    }

        }
    }
}

```

When I configure like this, and if I inspect this index

```auto
"mappings": {
  "_doc": {
    "properties": {
      "location": {
        "type": "geo_point"
      }
    }
  }
},

```

So I did this, I configure it manually and tried to insert my java classes it gives me error:

```auto
[type=illegal_argument_exception, reason=[location] is defined as an object in mapping [geofence] but this name is already used for a field in other types]]]

```

So types are mismatching. If I can configure and then insert java documents into my index it would be great, but I could not configure.

Basically I want to configure just fine to use geo query in ES. I can not directly insert because type is not going to be geo\_point. Or may be there will be some way?

Thanks for reading my issue

Update 2:

Now I am getting

[0]: index [geofence-whitelabe], type [geofence], id [1b7ce54c-5001-11e9-a4d2-35bbed2fa815], message [ElasticsearchException[Elasticsearch exception [type=mapper\_parsing\_exception, reason=failed to parse]]; nested: ElasticsearchException[Elasticsearch exception [type=parse\_exception, reason=field must be either lat/lon or geohash]];]

after configuring

```auto
PUT geofence-whitelabe
{
    "mappings": {
      "geofence": {
        "properties": {
          "ca": {
            "type": "date"
          },
          "del": {
            "type": "boolean"
          },
          "geofenceId": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "geofenceName": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "id": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "la": {
            "type": "date"
          },
                "location": {
                "type": "geo_point"
                        },
          "radius": {
            "type": "float"
          }
        }
      }
    }
}

```

---

<div class="post-metadata">

**Author:** ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)\
**Post date:** [March 29, 2019, 1:58pm UTC](https://discuss.elastic.co/t/i-can-not-use-geo-point-latitude-longitude-from-my-spring-application/173995/2 "2019-03-29T13:58:49Z")

</div>

It seems to be a spring mapping issue, not elasticsearch issue. So, you might get better help by asking on spting-specific forums. By the way, did you try using [`org.springframework.data.elasticsearch.core.geo.GeoPoint`](https://docs.spring.io/spring-data/elasticsearch/docs/current/api/org/springframework/data/elasticsearch/core/geo/GeoPoint.html) instead of elasticsearch's GeoPoint?

---

<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:** [April 26, 2019, 1:58pm UTC](https://discuss.elastic.co/t/i-can-not-use-geo-point-latitude-longitude-from-my-spring-application/173995/3 "2019-04-26T13:58:53Z")

</div>

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