# What is the difference between geo\_point and geohash in ELK? It is somehow becoming more difficult to write geodata into elastic using pure java code. Is there as specific library to use in Java or what is the way to go about it?

**URL:** <https://discuss.elastic.co/t/what-is-the-difference-between-geo-point-and-geohash-in-elk-it-is-somehow-becoming-more-difficult-to-write-geodata-into-elastic-using-pure-java-code-is-there-as-specific-library-to-use-in-java-or-what-is-the-way-to-go-about-it/175564>\
**Category:** Elasticsearch\
**Created:** [April 5, 2019, 10:04am UTC](https://discuss.elastic.co/t/what-is-the-difference-between-geo-point-and-geohash-in-elk-it-is-somehow-becoming-more-difficult-to-write-geodata-into-elastic-using-pure-java-code-is-there-as-specific-library-to-use-in-java-or-what-is-the-way-to-go-about-it/175564 "2019-04-05T10:04:33Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![ShilpaT](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shilpat/32/43553_2.png) [@ShilpaT](https://discuss.elastic.co/u/ShilpaT)\
**Post date:** [April 5, 2019, 10:04am UTC](https://discuss.elastic.co/t/what-is-the-difference-between-geo-point-and-geohash-in-elk-it-is-somehow-becoming-more-difficult-to-write-geodata-into-elastic-using-pure-java-code-is-there-as-specific-library-to-use-in-java-or-what-is-the-way-to-go-about-it/175564/1 "2019-04-05T10:04:33Z")

</div>

What is the difference between geo\_point and geohash in ELK? It is somehow becoming more difficult to write geodata into elastic using pure java code. Is there as specific library to use in Java or what is the way to go about it?  
I have tried many means to achieve this but none of them seem to work. Can you help please?

---

<div class="post-metadata">

**Author:** ![Ignacio\_Vera](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ignacio_vera/32/36674_2.png) [@Ignacio\_Vera](https://discuss.elastic.co/u/Ignacio_Vera)\
**Post date:** [April 5, 2019, 10:21am UTC](https://discuss.elastic.co/t/what-is-the-difference-between-geo-point-and-geohash-in-elk-it-is-somehow-becoming-more-difficult-to-write-geodata-into-elastic-using-pure-java-code-is-there-as-specific-library-to-use-in-java-or-what-is-the-way-to-go-about-it/175564/2 "2019-04-05T10:21:18Z")

</div>

Could you share a bit more information of what you are trying to do, for example which client are you using and different approaches taken?

---

<div class="post-metadata">

**Author:** ![ShilpaT](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shilpat/32/43553_2.png) [@ShilpaT](https://discuss.elastic.co/u/ShilpaT)\
**Post date:** [April 5, 2019, 11:27am UTC](https://discuss.elastic.co/t/what-is-the-difference-between-geo-point-and-geohash-in-elk-it-is-somehow-becoming-more-difficult-to-write-geodata-into-elastic-using-pure-java-code-is-there-as-specific-library-to-use-in-java-or-what-is-the-way-to-go-about-it/175564/3 "2019-04-05T11:27:36Z")

</div>

I am trying to insert some geo-points in the form of latitude and longitude using Java code. The scenario is: Elasticsearch and Kibana are installed on top of Docker on CentOS. Into that I am sending data using OSGi bundles written in Java. One of the data type is geo-points. Which is not getting stored as 'geo\_point' or 'geohash'. I have taken the reference from Flights sample data. And consulted the following links to understand inserting geo-data into Elastic database:

1. [https://www.baeldung.com/elasticsearch-geo-spatial](https://www.baeldung.com/elasticsearch-geo-spatial)
2. [https://www.elastic.co/guide/en/elasticsearch/reference/current/geo-point.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/geo-point.html)

The JSON mapping that I am sending from java code is inserting all of the data, but storing the location data as String. Which then cannot be visualized on Elastic Maps or?  
Plus, do I need to install something separately for Maps to work? I am using elasticsearch:6.5.3 and kibana:6.5.3.

Approaches taken were using external libraries to send geohash data directly from Java. Sample link:

1. [https://github.com/kungfoo/geohash-java](https://github.com/kungfoo/geohash-java)
2. [https://mvnrepository.com/artifact/ch.hsr/geohash/1.3.0](https://mvnrepository.com/artifact/ch.hsr/geohash/1.3.0)

---

<div class="post-metadata">

**Author:** ![Ignacio\_Vera](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ignacio_vera/32/36674_2.png) [@Ignacio\_Vera](https://discuss.elastic.co/u/Ignacio_Vera)\
**Post date:** [April 5, 2019, 11:42am UTC](https://discuss.elastic.co/t/what-is-the-difference-between-geo-point-and-geohash-in-elk-it-is-somehow-becoming-more-difficult-to-write-geodata-into-elastic-using-pure-java-code-is-there-as-specific-library-to-use-in-java-or-what-is-the-way-to-go-about-it/175564/4 "2019-04-05T11:42:09Z")

</div>

If you have defined the datatype of your field to `geo_point` but they are indexed as strings might mean there is a mismatch between your mapping and the document you are sending. You can try to set the dynamic property in your mapping to strict. If the above is true you should see an error:

[https://www.elastic.co/guide/en/elasticsearch/reference/6.7/dynamic.html](https://www.elastic.co/guide/en/elasticsearch/reference/6.7/dynamic.html)

You can post here your mapping and a example of the document you are sending if possible.

---

<div class="post-metadata">

**Author:** ![ShilpaT](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shilpat/32/43553_2.png) [@ShilpaT](https://discuss.elastic.co/u/ShilpaT)\
**Post date:** [April 5, 2019, 11:51am UTC](https://discuss.elastic.co/t/what-is-the-difference-between-geo-point-and-geohash-in-elk-it-is-somehow-becoming-more-difficult-to-write-geodata-into-elastic-using-pure-java-code-is-there-as-specific-library-to-use-in-java-or-what-is-the-way-to-go-about-it/175564/5 "2019-04-05T11:51:15Z")

</div>

You're right. I have the following mapping:

POST devmon:9200/event-2019.04.06/  
{  
"severity":"INFO",  
"hostname":"devats",  
"ComplaintJob.Location":"48.85544,9.1794",  
"@timestamp":1554456001686,  
"descriptor":"ComplaintJob",  
"message":"Complaint Resolved",  
"group":"Complaint"  
}

And the error received is:

"error": {  
"root\_cause": [  
{  
"type": "illegal\_argument\_exception",  
"reason": "Rejecting mapping update to [devmon:9200] as the final mapping would have more than 1 type: [event-2019.04.04-backup, event-2019.04.06]"  
}  
],  
"type": "illegal\_argument\_exception",  
"reason": "Rejecting mapping update to [devmon:9200] as the final mapping would have more than 1 type: [event-2019.04.04-backup, event-2019.04.06]"  
},  
"status": 400  
}

The PUT mapping will be needed everytime I insert a new field?

---

<div class="post-metadata">

**Author:** ![Ignacio\_Vera](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ignacio_vera/32/36674_2.png) [@Ignacio\_Vera](https://discuss.elastic.co/u/Ignacio_Vera)\
**Post date:** [April 5, 2019, 11:55am UTC](https://discuss.elastic.co/t/what-is-the-difference-between-geo-point-and-geohash-in-elk-it-is-somehow-becoming-more-difficult-to-write-geodata-into-elastic-using-pure-java-code-is-there-as-specific-library-to-use-in-java-or-what-is-the-way-to-go-about-it/175564/6 "2019-04-05T11:55:44Z")

</div>

What you post here is not the mapping but a document. You can get the mapping using the `GET mapping` API:

[https://www.elastic.co/guide/en/elasticsearch/reference/6.7/indices-get-mapping.html](https://www.elastic.co/guide/en/elasticsearch/reference/6.7/indices-get-mapping.html)

Mappings are defined once so no need to execute every time.

---

<div class="post-metadata">

**Author:** ![ShilpaT](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shilpat/32/43553_2.png) [@ShilpaT](https://discuss.elastic.co/u/ShilpaT)\
**Post date:** [April 5, 2019, 12:01pm UTC](https://discuss.elastic.co/t/what-is-the-difference-between-geo-point-and-geohash-in-elk-it-is-somehow-becoming-more-difficult-to-write-geodata-into-elastic-using-pure-java-code-is-there-as-specific-library-to-use-in-java-or-what-is-the-way-to-go-about-it/175564/7 "2019-04-05T12:01:07Z")

</div>

Query: GET event-2019.04.04/\_mapping/\_doc

Mapping:  
{  
"event-2019.04.04" : {  
"mappings" : {  
"\_doc" : {  
"dynamic\_templates" : [  
{  
"only\_keyword" : {  
"match\_mapping\_type" : "string",  
"mapping" : {  
"type" : "keyword"  
}  
}  
}  
],  
"properties" : {  
"@timestamp" : {  
"type" : "date"  
},  
"client" : {  
"type" : "keyword"  
},  
"descriptor" : {  
"type" : "keyword"  
},  
"group" : {  
"type" : "keyword"  
},  
"hostname" : {  
"type" : "keyword"  
},  
"location" : {  
"properties" : {  
"lat" : {  
"type" : "float"  
},  
"lon" : {  
"type" : "float"  
},  
"type:" : {  
"type" : "keyword"  
}  
}  
},  
"message" : {  
"type" : "text"  
},  
"severity" : {  
"type" : "keyword"  
}  
}  
}  
}  
}  
}

---

<div class="post-metadata">

**Author:** ![Ignacio\_Vera](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ignacio_vera/32/36674_2.png) [@Ignacio\_Vera](https://discuss.elastic.co/u/Ignacio_Vera)\
**Post date:** [April 5, 2019, 12:22pm UTC](https://discuss.elastic.co/t/what-is-the-difference-between-geo-point-and-geohash-in-elk-it-is-somehow-becoming-more-difficult-to-write-geodata-into-elastic-using-pure-java-code-is-there-as-specific-library-to-use-in-java-or-what-is-the-way-to-go-about-it/175564/8 "2019-04-05T12:22:40Z")

</div>

As you can see in the mapping, there is no `geo_point` field. There is a field called `location.lat` and another `location.lon` of type float.

There is something estrange because in your document the point is under the following field: `"ComplaintJob.Location":"48.85544,9.1794"`. It does not match but I see that data and mappings come from different index: `event-2019.04.04` vs `event-2019.04.06`

For example if I create this mapping:

```auto
PUT /event-2019.04.04/_mapping/_doc
{
  "dynamic": "strict",
  "properties": {
    "@timestamp": {
      "type": "date"
    },
    "client": {
      "type": "keyword"
    },
    "descriptor": {
      "type": "keyword"
    },
    "group": {
      "type": "keyword"
    },
    "hostname": {
      "type": "keyword"
    },
    "ComplaintJob.Location": {
          "type": "geo_point"
    },
    "message": {
      "type": "text"
    },
    "severity": {
      "type": "keyword"
    }
  }
}

```

Then I can successfully ingest the document you sent.

---

<div class="post-metadata">

**Author:** ![ShilpaT](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shilpat/32/43553_2.png) [@ShilpaT](https://discuss.elastic.co/u/ShilpaT)\
**Post date:** [April 8, 2019, 11:02am UTC](https://discuss.elastic.co/t/what-is-the-difference-between-geo-point-and-geohash-in-elk-it-is-somehow-becoming-more-difficult-to-write-geodata-into-elastic-using-pure-java-code-is-there-as-specific-library-to-use-in-java-or-what-is-the-way-to-go-about-it/175564/9 "2019-04-08T11:02:04Z")

</div>

It worked 😊  
On Friday itself, letting you know. Vielen Sehr Dank for the help.

---

<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:** [May 6, 2019, 11:02am UTC](https://discuss.elastic.co/t/what-is-the-difference-between-geo-point-and-geohash-in-elk-it-is-somehow-becoming-more-difficult-to-write-geodata-into-elastic-using-pure-java-code-is-there-as-specific-library-to-use-in-java-or-what-is-the-way-to-go-about-it/175564/10 "2019-05-06T11:02:06Z")

</div>

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