Analyzing Product Sales Data
Let’s consider an example where we have sales data for a retail store. We want to identify significant products that have higher sales compared to the overall average.
Indexing Data
PUT /sales_data/_doc/1
{
"product": "iPhone",
"sales": 100
}
PUT /sales_data/_doc/2
{
"product": "Samsung Galaxy",
"sales": 80
}
PUT /sales_data/_doc/3
{
"product": "iPad",
"sales": 120
}
Performing Significant Aggregation
GET /sales_data/_search
{
"size": 0,
"aggs": {
"significant_products": {
"significant_terms": {
"field": "product",
"size": 10
}
}
}
}
Output:
{
"aggregations": {
"significant_products": {
"doc_count": 3,
"bg_count": 3,
"buckets": [
{
"key": "iPhone",
"doc_count": 1,
"score": 1.0
},
{
"key": "iPad",
"doc_count": 1,
"score": 1.0
},
{
"key": "Samsung Galaxy",
"doc_count": 1,
"score": 1.0
}
]
}
}
}
Analysis:
- All products have a score of 1.0, indicating that they are equally significant compared to the background set.
- In this simple example, all products have the same sales count, so they are equally significant.
Significant Aggregation in Elasticsearch
Elasticsearch provides a wide range of aggregation capabilities to analyze data in various ways. One powerful aggregation is the Significant Aggregation, which helps identify significant terms or buckets within a dataset. In this guide, we’ll delve into the Significant Aggregation in Elasticsearch, exploring its functionality, use cases, and how to implement it with examples and outputs.
Contact Us