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.
Query
GET /products/_search
{
"query": {
"term": {
"category.keyword": "electronics"
}
},
"size": 0,
"aggs": {
"significant_terms": {
"significant_terms": {
"field": "name.keyword"
}
}
}
}
Output
{
"aggregations": {
"significant_terms": {
"buckets": [
{
"key": "laptop",
"doc_count": 3,
"score": 0.5,
"bg_count": 1
},
{
"key": "tablet",
"doc_count": 2,
"score": 0.3,
"bg_count": 1
}
]
}
}
}
In this example, significant terms in product names in the electronics category are identified, with their document counts and significance scores.
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.