Geohash Grid Aggregation

The geohash grid aggregation groups geo-point data into geohash cells. Let’s group products by their location.

Query

GET /products/_search
{
"size": 0,
"aggs": {
"geo_grid": {
"geohash_grid": {
"field": "location",
"precision": 5
}
}
}
}

Output

{
"aggregations": {
"geo_grid": {
"buckets": [
{
"key": "dr5ru",
"doc_count": 3
},
{
"key": "dr5r6",
"doc_count": 2
}
]
}
}
}

In this example, products are grouped by their location into geohash cells with a precision of 5.

Bucket Aggregation in Elasticsearch

Elasticsearch is a robust tool not only for full-text search but also for data analytics. One of the core features that make Elasticsearch powerful is its aggregation framework, particularly bucket aggregations. Bucket aggregations allow you to group documents into buckets based on certain criteria, making it easier to analyze and summarize your data.

This article will explain what bucket aggregations are, how they work, and provide detailed examples to help you understand their usage.

Similar Reads

What are Bucket Aggregations?

Bucket aggregations in Elasticsearch are used to group documents into different buckets based on specified criteria. Each bucket can contain multiple documents that match the criteria. Unlike metric aggregations, which calculate metrics on numeric fields, bucket aggregations focus on grouping data....

Types of Bucket Aggregations

Elasticsearch provides several types of bucket aggregations, each suited for different grouping scenarios:...

Terms Aggregation

The term aggregation groups documents based on the unique values in a field. Let’s group products by their category....

Histogram Aggregation

The histogram aggregation groups numeric values into buckets of a specified interval. Let’s group products by price ranges with an interval of $100....

Date Histogram Aggregation

The date histogram aggregation groups date values into buckets of a fixed time interval. Let’s group products by the month they were sold....

Range Aggregation

The range aggregation groups numeric values into custom ranges. Let’s group products by custom price ranges....

Date Range Aggregation

The date range aggregation groups date values into custom ranges. Let’s group products by custom-sold date ranges....

Filter Aggregation

The filter aggregation groups documents that match a specific filter. Let’s group products that have a rating of 4 or higher....

Filters Aggregation

The filter aggregation groups documents based on multiple filters. Let’s group products based on multiple rating ranges....

Significant Terms Aggregation

The significant terms aggregation finds unusual terms in a set of documents. Let’s find significant terms in product names in the electronics category....

Geohash Grid Aggregation

The geohash grid aggregation groups geo-point data into geohash cells. Let’s group products by their location....

Conclusion

Bucket aggregations in Elasticsearch are a powerful tool for grouping and analyzing data based on various criteria. By understanding and using different types of bucket aggregations, you can perform complex analytics and gain valuable insights into your data. Whether you’re analyzing sales data, user behavior, or any other type of information, bucket aggregations provide a flexible and efficient way to summarize and explore your data in Elasticsearch....

Contact Us