# Geohash graph

**URL:** <https://discuss.elastic.co/t/geohash-graph/132837>\
**Category:** Kibana\
**Tags:** elastic-stack-graph\
**Created:** [May 22, 2018, 2:12pm UTC](https://discuss.elastic.co/t/geohash-graph/132837 "2018-05-22T14:12:00Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![akml\_kk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/akml_kk/32/31069_2.png) [@akml\_kk](https://discuss.elastic.co/u/akml_kk)\
**Post date:** [May 22, 2018, 2:12pm UTC](https://discuss.elastic.co/t/geohash-graph/132837/1 "2018-05-22T14:12:00Z")

</div>

I m planning to create a graph to visualize the relation between different cabs pickups location in Nyc city.  
so i choosed the index named "green" (for green cabs) and the field pickup\_location (which is type is geohash), the result is 500 server error !?

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [May 22, 2018, 2:22pm UTC](https://discuss.elastic.co/t/geohash-graph/132837/2 "2018-05-22T14:22:26Z")

</div>

Can you share the mapping and the stacktrace?

I expect you want to map the value as a `keyword` type if you are using it as a location identifier - geo fields are optimised for spatial range queries rather than ID-type lookups.

---

<div class="post-metadata">

**Author:** ![akml\_kk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/akml_kk/32/31069_2.png) [@akml\_kk](https://discuss.elastic.co/u/akml_kk)\
**Post date:** [May 22, 2018, 2:38pm UTC](https://discuss.elastic.co/t/geohash-graph/132837/3 "2018-05-22T14:38:43Z")

</div>

this is the stacktrace i took a screenshot

 ![stacktrace](https://us1.discourse-cdn.com/elastic/original/3X/0/1/012b16890c0d6881d756bcc8e9733bbab5eef944.png)  
what you mean by mapping ? template mapping for geopoint ?

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [May 22, 2018, 2:54pm UTC](https://discuss.elastic.co/t/geohash-graph/132837/4 "2018-05-22T14:54:45Z")

</div>

> [@akml\_kk](#):
>
> what you mean by mapping ?

Mappings are effectively the schema for your index - see [Mapping | Elasticsearch Guide [8.11] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping.html)

Here's an example of trips from JFK to Brooklyn and Queens which you can paste into Kibana's console:

```
DELETE test
PUT test
{
  "mappings": {
	"trip": {
	  "properties": {
		"geo": {
		  "type": "geo_point",
		  "fields":{
			"keyword":{
			  "type":"keyword"
			}
		  }
		}
	  }
	}
  }
}

POST test/trip/_bulk
{"index":{}}
{ "geo":["dr5x2bn", "dr5x8v1"] }
{"index":{}}
{ "geo":["dr5x2bn", "dr5rmks"]}

GET test/_search
{
  "size": 0,
  "aggs": {
	"terms": {
	  "terms": {
		"field": "geo.keyword"
	  }
	}
  }
}

```

Note that I mapped the JSON value as both a `geo_point` field and a `keyword` field - one is for spatial queries, the other for ID-based queries of the sort Graph uses.

---

<div class="post-metadata">

**Author:** ![akml\_kk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/akml_kk/32/31069_2.png) [@akml\_kk](https://discuss.elastic.co/u/akml_kk)\
**Post date:** [May 22, 2018, 10:40pm UTC](https://discuss.elastic.co/t/geohash-graph/132837/5 "2018-05-22T22:40:49Z")

</div>

Ok, understood i this is the mapping of the index green

```
{
  "green": {
"mappings": {
  "traj": {
    "properties": {
      "@timestamp": {
        "type": "date"
      },
      "@version": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      },
      "Dropoff_location": {
        "type": "geo_point"
      },
      "Extra": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      },
      "Fare_amount": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      },
      "Lpep_dropoff_datetime": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      },
      "MTA_tax": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      },
      "Passenger_count": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      },
      "Payment_type": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      },
      "PickupDate": {
        "type": "date"
      },
      "Pickup_location": {
        "type": "geo_point"
      },
      "RateCodeID": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      },
      "Store_and_fwd_flag": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      },
      "Tip_amount": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      },
      "Tolls_amount": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      },
      "Total_amount": {
        "type": "float"
      },
      "Trip_distance": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      },
      "Trip_type": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      },
      "VendorID": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      },
      "host": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      },
      "lpep_pickup_datetime": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      },
      "message": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      },
      "path": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      }
    }
  },
  "_default_": {
    "properties": {
      "Dropoff_location": {
        "type": "geo_point"
      },
      "Pickup_location": {
           "type": "geo_point"
         }
       }
     }
   }
}
}
```

---

<div class="post-metadata">

**Author:** ![akml\_kk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/akml_kk/32/31069_2.png) [@akml\_kk](https://discuss.elastic.co/u/akml_kk)\
**Post date:** [May 24, 2018, 8:49pm UTC](https://discuss.elastic.co/t/geohash-graph/132837/6 "2018-05-24T20:49:11Z")

</div>

so ?

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [May 25, 2018, 7:51am UTC](https://discuss.elastic.co/t/geohash-graph/132837/7 "2018-05-25T07:51:20Z")

</div>

I suggest you create a new field called "my\_location\_keywords" mapped as a `keyword` type.  
You should pass docs, as in my example, where the pickup and dropoff points are expressed as 2 truncated geohashes in the "my\_location\_keywords" array. Why truncated? Full-resolution geohashes will likely lead to a graph with millions of nodes each containing exactly one doc per connection - every full-precision pickup/dropoff location may be unique. If you truncate the geohash [according to this table](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-geohashgrid-aggregation.html#_cell_dimensions_at_the_equator) you'll "round up" to a higher level view of the data.

If your original data is lat/lon you can find geohash implementations for a variety of languages.

---

<div class="post-metadata">

**Author:** ![akml\_kk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/akml_kk/32/31069_2.png) [@akml\_kk](https://discuss.elastic.co/u/akml_kk)\
**Post date:** [May 25, 2018, 2:11pm UTC](https://discuss.elastic.co/t/geohash-graph/132837/8 "2018-05-25T14:11:35Z")

</div>

Ok, I did as you told me:  
i changed my mapping for the index like this :

```
PUT _template/test
{
  "order":0,
  "index_patterns":"test",
"mappings":{
  "_default_":{
    "properties":{
      "Pickup_location":{
        "type":"geo_point"
        ,"fields":{
          "keyword":{
            "type":"keyword"
          }
        }
      },
      "Dropoff_location":{
        "type":"geo_point"
        ,"fields":{
          "keyword":{
            "type":"keyword"
             }
           }
         }
       }
     }
   }
}

```

then i indexed with logstash the test index.  
the result i still don't see the graph created when i choice test as index and pickup\_location.keyword as a field, but the error is gone.  
i don't undesrstand the truncated part of geohash since the ingestion is done by logstash

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [May 25, 2018, 2:28pm UTC](https://discuss.elastic.co/t/geohash-graph/132837/9 "2018-05-25T14:28:51Z")

</div>

> [@akml\_kk](#):
>
> i don't undesrstand the truncated part of geohash since the ingestion is done by logstash

You need to write some code or dig deeper into what logstash can do for you in terms of document preparation.

---

<div class="post-metadata">

**Author:** ![akml\_kk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/akml_kk/32/31069_2.png) [@akml\_kk](https://discuss.elastic.co/u/akml_kk)\
**Post date:** [May 25, 2018, 4:16pm UTC](https://discuss.elastic.co/t/geohash-graph/132837/10 "2018-05-25T16:16:36Z")

</div>

ok , but even your example dosen't work for me.  
i chosed the pickup\_location as a field

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [May 25, 2018, 4:35pm UTC](https://discuss.elastic.co/t/geohash-graph/132837/11 "2018-05-25T16:35:29Z")

</div>

> [@akml\_kk](#):
>
> ok , but even your example dosen't work for me.

Working here with these GUI settings on 6.2.3

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/b/d/bda67befa5d29297d236f87bda8e9bd463c49f6f.png)

---

<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:** [June 22, 2018, 4:35pm UTC](https://discuss.elastic.co/t/geohash-graph/132837/12 "2018-06-22T16:35:30Z")

</div>

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