# Geohash Aggregation min\_doc\_count Usage

**URL:** <https://discuss.elastic.co/t/geohash-aggregation-min-doc-count-usage/145832>\
**Category:** Kibana\
**Created:** [August 24, 2018, 4:13am UTC](https://discuss.elastic.co/t/geohash-aggregation-min-doc-count-usage/145832 "2018-08-24T04:13:10Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![bpalfaro](https://avatars.discourse-cdn.com/v4/letter/b/f4b2a3/32.png) [@bpalfaro](https://discuss.elastic.co/u/bpalfaro)\
**Post date:** [August 24, 2018, 4:13am UTC](https://discuss.elastic.co/t/geohash-aggregation-min-doc-count-usage/145832/1 "2018-08-24T04:13:11Z")

</div>

Hello,

I want to know how to filter the response records to only show aggregation geohash counts greater than 10 records. I've attempted the json input in Terms such as {"min\_doc\_count": 10}. I've also tried to use a bucket selector in Aggregation json input field but the bucket filter shows in the wrong aggregation so the fields are invalid.

Here is the example request:

{  
"size": 0,  
"\_source": {  
"excludes": []  
},  
"aggs": {  
"filter\_agg": {  
"filter": {  
"geo\_bounding\_box": {  
"settings.events.alerts.loc.coordinates": {  
"top\_left": {  
"lat": 63.8412,  
"lon": -156.577155  
},  
"bottom\_right": {  
"lat": 6.120279999999999,  
"lon": -36.69433500000001  
}  
}  
}  
},  
"aggs": {  
"2": {  
"geohash\_grid": {  
"field": "settings.events.alerts.loc.coordinates",  
"precision": 3  
},  
"aggs": {  
"3": {  
"geo\_centroid": {  
"field": "settings.events.alerts.loc.coordinates"  
}  
}  
}  
}  
}  
}  
},  
"stored\_fields": [  
"\*"  
],  
"script\_fields": {},  
"docvalue\_fields": [  
"createdAt",  
"license.acceptedOn",  
"created\_at",  
"updated\_at",  
"updatedAt"  
],  
"query": {  
"bool": {  
"must": [  
{  
"match\_all": {}  
}  
],  
"filter": [],  
"should": [],  
"must\_not": []  
}  
}  
}

---

<div class="post-metadata">

**Author:** ![Marius\_Dragomir](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marius_dragomir/32/42087_2.png) [@Marius\_Dragomir](https://discuss.elastic.co/u/Marius_Dragomir)\
**Post date:** [August 24, 2018, 10:28am UTC](https://discuss.elastic.co/t/geohash-aggregation-min-doc-count-usage/145832/2 "2018-08-24T10:28:51Z")

</div>

Hello,

The {"min\_doc\_count": 10} should have worked for this. What is the result when you use this?

---

<div class="post-metadata">

**Author:** ![bpalfaro](https://avatars.discourse-cdn.com/v4/letter/b/f4b2a3/32.png) [@bpalfaro](https://discuss.elastic.co/u/bpalfaro)\
**Post date:** [August 24, 2018, 8:32pm UTC](https://discuss.elastic.co/t/geohash-aggregation-min-doc-count-usage/145832/3 "2018-08-24T20:32:15Z")

</div>

Thanks for the quick reply

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/9/e/9e48f4a756a61195002b4e3b886714ef83ec218b.png)

Attached an image of the coordinate map json input in the metrics section and the request and reply. I don't even see the json input in the request.

REQUEST  
{  
"size": 0,  
"\_source": {  
"excludes":   
},  
"aggs": {  
"filter\_agg": {  
"filter": {  
"geo\_bounding\_box": {  
"settings.events.alerts.loc.coordinates": {  
"top\_left": {  
"lat": 43.45082,  
"lon": -111.599125  
},  
"bottom\_right": {  
"lat": 28.949180000000002,  
"lon": -81.62841499999999  
}  
}  
}  
},  
"aggs": {  
"2": {  
"geohash\_grid": {  
"field": "settings.events.alerts.loc.coordinates",  
"precision": 4  
},  
"aggs": {  
"3": {  
"geo\_centroid": {  
"field": "settings.events.alerts.loc.coordinates"  
}  
}  
}  
}  
}  
}  
},  
"stored\_fields": [  
"\*"  
],  
"script\_fields": {},  
"docvalue\_fields": [  
"createdAt",  
"license.acceptedOn",  
"created\_at",  
"updated\_at",  
"updatedAt"  
],  
"query": {  
"bool": {  
"must": [  
{  
"match\_all": {}  
}  
],  
"filter": ,  
"should": ,  
"must\_not":   
}  
}  
}

RESPONSE

{  
"took": 15,  
"timed\_out": false,  
"\_shards": {  
"total": 5,  
"successful": 5,  
"skipped": 0,  
"failed": 0  
},  
"hits": {  
"total": 556,  
"max\_score": 0,  
"hits":   
},  
"aggregations": {  
"filter\_agg": {  
"2": {  
"buckets": [  
{  
"3": {  
"location": {  
"lat": 36.100095140102965,  
"lon": -95.9068003612069  
},  
"count": 117  
},  
"key": "9y7v",  
"doc\_count": 117  
},  
{  
"3": {  
"location": {  
"lat": 36.13772970068841,  
"lon": -95.99905315382652  
},  
"count": 83  
},  
"key": "9y7t",  
"doc\_count": 83  
},  
{  
"3": {  
"location": {  
"lat": 36.00544908123889,  
"lon": -95.88678067097706  
},  
"count": 70  
},  
"key": "9y7u",  
"doc\_count": 70  
},  
{  
"3": {  
"location": {  
"lat": 35.433654902502894,  
"lon": -97.53190651988345  
},  
"count": 35  
},  
"key": "9y69",  
"doc\_count": 35  
},  
{  
"3": {  
"location": {  
"lat": 35.58408369831741,  
"lon": -97.5404976401478  
},  
"count": 25  
},  
"key": "9y6d",  
"doc\_count": 25  
},  
{  
"3": {  
"location": {  
"lat": 36.12792001825503,  
"lon": -94.15774438276209  
},  
"count": 22  
},  
"key": "9ymj",  
"doc\_count": 22  
},  
{  
"3": {  
"location": {  
"lat": 36.28046694677323,  
"lon": -95.83723620977253  
},  
"count": 18  
},  
"key": "9y7y",  
"doc\_count": 18  
},  
{  
"3": {  
"location": {  
"lat": 36.007640613242984,  
"lon": -96.00622740201652  
},  
"count": 15  
},  
"key": "9y7s",  
"doc\_count": 15  
},  
{  
"3": {  
"location": {  
"lat": 35.24379782192409,  
"lon": -97.47573391813785  
},  
"count": 10  
},  
"key": "9y68",  
"doc\_count": 10  
},  
{  
"3": {  
"location": {  
"lat": 36.306617485242896,  
"lon": -94.16065075434744  
},  
"count": 8  
},  
"key": "9ymn",  
"doc\_count": 8  
},  
{  
"3": {  
"location": {  
"lat": 35.417209239676595,  
"lon": -97.32800040207803  
},  
"count": 5  
},  
"key": "9y6c",  
"doc\_count": 5  
},  
{  
"3": {  
"location": {  
"lat": 32.961370870471,  
"lon": -97.15120348334312  
},  
"count": 5  
},  
"key": "9vfg",  
"doc\_count": 5  
},  
{  
"3": {  
"location": {  
"lat": 37.69802705850452,  
"lon": -97.23394480766729  
},  
"count": 4  
},  
"key": "9ydy",  
"doc\_count": 4  
},  
..............TRUNCATED.....................  
]  
},  
"doc\_count": 506  
}  
},  
"status": 200  
}

---

<div class="post-metadata">

**Author:** ![Marius\_Dragomir](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marius_dragomir/32/42087_2.png) [@Marius\_Dragomir](https://discuss.elastic.co/u/Marius_Dragomir)\
**Post date:** [August 27, 2018, 12:00pm UTC](https://discuss.elastic.co/t/geohash-aggregation-min-doc-count-usage/145832/4 "2018-08-27T12:00:49Z")

</div>

You need to click on the "Advanced" label in the bottom of the picture (in the bucket part of the chart) and then you will see a "JSON input" field in there. That is where you need to use the `{"min_doc_count": 10}`.

---

<div class="post-metadata">

**Author:** ![bpalfaro](https://avatars.discourse-cdn.com/v4/letter/b/f4b2a3/32.png) [@bpalfaro](https://discuss.elastic.co/u/bpalfaro)\
**Post date:** [August 27, 2018, 5:52pm UTC](https://discuss.elastic.co/t/geohash-aggregation-min-doc-count-usage/145832/5 "2018-08-27T17:52:25Z")

</div>

Hey Marius,

Yes I did try that before but I got an error. Here it is for your review.

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/c/1/c1c39edfd1956722484e7f6ba14f873868e0362f.png)

---

<div class="post-metadata">

**Author:** ![Marius\_Dragomir](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marius_dragomir/32/42087_2.png) [@Marius\_Dragomir](https://discuss.elastic.co/u/Marius_Dragomir)\
**Post date:** [August 28, 2018, 5:03pm UTC](https://discuss.elastic.co/t/geohash-aggregation-min-doc-count-usage/145832/6 "2018-08-28T17:03:42Z")

</div>

Yes, I've looked at the code for geohash\_grid aggregations in Elasticsearch and it seems it doesn't support `min_doc_count`.  
If you were just getting the query results, you could use something like `bucket_selector` to emulate min\_doc\_count, but this isn't possible to do in Kibana right now.

> [@How to use the Bucket Selector to emulate min\_doc\_count?](https://discuss.elastic.co/t/how-to-use-the-bucket-selector-to-emulate-min-doc-count/37049):
>
> I want to eliminate all empty buckets from a range aggregation. According to [https://github.com/elastic/elasticsearch/issues/10027](https://github.com/elastic/elasticsearch/issues/10027) the [Bucket Selector Pipeline Aggregation](https://www.elastic.co/guide/en/elasticsearch/reference/2.1/search-aggregations-pipeline-bucket-selector-aggregation.html#issuecomment-162449165) is the way to go, but I'm struggling with its syntax. Here's what I have so far: { "aggs": { "values\_histogram": { "range": { "field": "value", "ranges": [{ "from": 1, "to": 2 }, { "from": 2, "to": 3 }, { "from": 3, "to": 4 }] }, "aggs": { …

---

<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:** [September 25, 2018, 5:03pm UTC](https://discuss.elastic.co/t/geohash-aggregation-min-doc-count-usage/145832/7 "2018-09-25T17:03:42Z")

</div>

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