Geohash Aggregation min_doc_count Usage

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": []
}
}
}

Hello,

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

Thanks for the quick reply

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
}

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}.

Hey Marius,

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

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.

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