SlideShare uma empresa Scribd logo
1 de 22
Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission is strictly
Introduction to Aggregations
Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission is strictly
facets (elasticsearch < 1.0)
facets
Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission is strictly
out-of-the-box facets
(elasticsearch < 1.0)
• terms
• range
• histogram / date histogram
• filter/query
• statistical
• geo distance
Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission is strictly
terms facet
• Divides documents into buckets based on a value
of a selected term
• Calculates statistics on some other field of these
document for each bucket
Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission is strictly
index of large US cities
{
"rank": "21",
"city": "Boston",
"state": "MA",
"population2012": "636479",
"population2010": "617594",
"land_area": "48.277",
"density": "12793",
"ansi": "619463",
"location": {
"lat": "42.332",
"lon": "71.0202"
}
}
Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission is strictly
example: terms facet request
$ curl -XGET "localhost:9200/test-data/cities/_search?pretty" -d '{
"facets": {
"stat1": {
"terms_stats": {
"key_field": "state",
"value_field": "density"
}
}
}
}'
group by
this field
calculate stats
for this field
Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission is strictly
example: terms facet response
"facets" : {
"stat1" : {
"_type" : "terms_stats",
"missing" : 0,
"terms" : [ {
"term" : "CA",
"count" : 69,
"total_count" : 69,
"min" : 1442.0,
"max" : 17179.0,
"total" : 383545.0,
"mean" : 5558.623188405797
}, {
"term" : "TX",
"count" : 32,
"total_count" : 32,
"min" : 1096.0,
"max" : 3974.0,
"total" : 79892.0,
"mean" : 2496.625
}, {
"term" : "FL",
"count" : 20,
"total_count" : 20,
"min" : 1100.0,
"max" : 11136.0,
"total" : 80132.0,
group by
field
stats
Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission is strictly
example: range facet request
curl -XGET "localhost:9200/test-data/cities/_search?pretty" -d '{
"facets": {
"population_ranges": {
"histogram": {
"key_field": "population2012",
"value_field": "density",
"interval": 500000
}
}
}
}'
group by
this field
calculate stats
by this field
Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission is strictly
example: terms facet response
"facets" : {
"population_ranges" : {
"_type" : "histogram",
"entries" : [ {
"key" : 0,
"count" : 255,
"min" : 171.0,
"max" : 17346.0,
"total" : 980306.0,
"total_count" : 252,
"mean" : 3890.1031746031745
}, {
"key" : 500000,
"count" : 25,
"min" : 956.0,
"max" : 17179.0,
"total" : 116597.0,
"total_count" : 25,
"mean" : 4663.88
}, {
"key" : 1000000,
"count" : 4,
"min" : 2798.0,
"max" : 4020.0,
"total" : 13216.0,
"total_count" : 4,
"mean" : 3304.0
group by
field (population)
stats
(density)
Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission is strictly
nt an average density by population histogram
Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission is strictly
aggregations
Buckets Calculators
Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission is strictly
aggregations = buckets + calculators
CA
TX
MA
CO
AZ
"facets" : {
"population_ranges" : {
"_type" : "histogram",
"entries" : [ {
"key" : 0,
"count" : 255,
"min" : 171.0,
"max" : 17346.0,
"total" : 980306.0,
"total_count" : 252,
"mean" : 3890.1031746031745
}, {
"key" : 500000,
"count" : 25,
"min" : 956.0,
"max" : 17179.0,
"total" : 116597.0,
"total_count" : 25,
"mean" : 4663.88
}, {
"key" : 1000000,
"count" : 4,
"min" : 2798.0,
"max" : 4020.0,
"total" : 13216.0,
"total_count" : 4,
"mean" : 3304.0
}, {
Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission is strictly
aggregations = buckets + calculators
CA
TX
MA
CO
AZ
Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission is strictly
example: density by state aggregation
$ curl -XGET "localhost:9200/test-data/cities/_search?pretty" -d '{
"aggs" : {
"mean_density_by_state" : {
"terms" : {
"field" : "state"
},
"aggs": {
"mean_density": {
"avg" : {
"field" : "density"
}
}
}
}
}
}'
group by
this field
calculate stats
for this field
Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission is strictly
aggregation response
"aggregations" : {
"mean_density_by_state" : {
"terms" : [ {
"term" : "CA",
"doc_count" : 69,
"mean_density" : {
"value" : 5558.623188405797
}
}, {
"term" : "TX",
"doc_count" : 32,
"mean_density" : {
"value" : 2496.625
}
}, {
"term" : "FL",
"doc_count" : 20,
"mean_density" : {
"value" : 4006.6
}
}, {
"term" : "CO",
"doc_count" : 11,
"mean_density" : {
"value" : 2944.4
}
}, {
group by
state
density stats
Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission is strictly
example: density by population aggregation
$ curl -XGET "localhost:9200/test-data/cities/_search?pretty" -d '{
"aggs" : {
"mean_density_by_population" : {
"histogram" : {
"field" : "population2012",
"interval": 500000
},
"aggs": {
"mean_density": {
"avg" : {
"field" : "density"
}
}
}
}
}
}'
group by
population
calculate stats
density
Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission is strictly
aggregation response
"aggregations" : {
"mean_density_by_population" : [ {
"key" : 0,
"doc_count" : 255,
"mean_density" : {
"value" : 3890.1031746031745
}
}, {
"key" : 500000,
"doc_count" : 25,
"mean_density" : {
"value" : 4663.88
}
}, {
"key" : 1000000,
"doc_count" : 4,
"mean_density" : {
"value" : 3304.0
}
}, {
"key" : 1500000,
"doc_count" : 1,
"mean_density" : {
"value" : 11379.0
}
group by
population
density stats
Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission is strictly
example: density by population by state
$ curl -XGET "localhost:9200/test-data/cities/_search?pretty" -d '{
"aggs" : {
"mean_density_by_population_by_state": {
"terms" : { "field" : "state" },
"aggs": {
"mean_density_by_population" : {
"histogram" : {
"field" : "population2012",
"interval": 500000
},
"aggs": {
"mean_density": {
"avg" : {
"field" : "density"
}
}
}
}
}
}
}
}'
group by
population
calculate stats
on density
group by
state
Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission is strictly
aggregation response"aggregations" : {
"mean_density_by_population_by_state" : {
"terms" : [ {
"term" : "CA",
"doc_count" : 69,
"mean_density_by_population" : [ {
"key" : 0,
"doc_count" : 64,
"mean_density" : {
"value" : 5382.453125
}
}, {
"key" : 500000,
"doc_count" : 3,
"mean_density" : {
"value" : 8985.333333333334
}
}, {
"key" : 1000000,
"doc_count" : 1,
"mean_density" : {
"value" : 4020.0
}
}, {
"key" : 3500000,
"doc_count" : 1,
"mean_density" : {
"value" : 8092.0
}
} ]
}, {
"term" : "TX",
"doc_count" : 32,
"mean_density_by_population" : [ {
"key" : 0,
"doc_count" : 26,
"mean_density" : {
"value" : 2408.3076923076924
group by
population
stats on density
group by state
Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission is strictly
out-of-the-box aggregation calculators
(elasticsearch >= 1.0)
• avg
• min
• max
• sum
• count
• stats
• extended stats
Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission is strictly
out-of-the-box aggregation bucketizers
(elasticsearch >= 1.0)
• global
• filter
• missing
• terms
• range
• date range
• ip range
• histogram
• date histogram
• geo distance
• nested
Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission is strictly
aggregations 2.0 (aka bucket reducers)
(elasticsearch 2.0)
apply arbitrary functions on buckets
• first derivative
• second derivative
• exponential weighted moving average
• outlier detection

Mais conteúdo relacionado

Mais procurados

Mais procurados (20)

Elasticsearch 5.0
Elasticsearch 5.0Elasticsearch 5.0
Elasticsearch 5.0
 
Elasticsearch - DevNexus 2015
Elasticsearch - DevNexus 2015Elasticsearch - DevNexus 2015
Elasticsearch - DevNexus 2015
 
Introduction to elasticsearch
Introduction to elasticsearchIntroduction to elasticsearch
Introduction to elasticsearch
 
Elasticsearch
ElasticsearchElasticsearch
Elasticsearch
 
Introduction to Elasticsearch
Introduction to ElasticsearchIntroduction to Elasticsearch
Introduction to Elasticsearch
 
Simple search with elastic search
Simple search with elastic searchSimple search with elastic search
Simple search with elastic search
 
Elasticsearch War Stories
Elasticsearch War StoriesElasticsearch War Stories
Elasticsearch War Stories
 
Intro to Elasticsearch
Intro to ElasticsearchIntro to Elasticsearch
Intro to Elasticsearch
 
ElasticSearch - DevNexus Atlanta - 2014
ElasticSearch - DevNexus Atlanta - 2014ElasticSearch - DevNexus Atlanta - 2014
ElasticSearch - DevNexus Atlanta - 2014
 
Java clients for elasticsearch
Java clients for elasticsearchJava clients for elasticsearch
Java clients for elasticsearch
 
Elasticsearch quick Intro (English)
Elasticsearch quick Intro (English)Elasticsearch quick Intro (English)
Elasticsearch quick Intro (English)
 
Joins and Other MongoDB 3.2 Aggregation Enhancements
Joins and Other MongoDB 3.2 Aggregation EnhancementsJoins and Other MongoDB 3.2 Aggregation Enhancements
Joins and Other MongoDB 3.2 Aggregation Enhancements
 
Elasticsearch - under the hood
Elasticsearch - under the hoodElasticsearch - under the hood
Elasticsearch - under the hood
 
Elasticsearch presentation 1
Elasticsearch presentation 1Elasticsearch presentation 1
Elasticsearch presentation 1
 
Elastic search overview
Elastic search overviewElastic search overview
Elastic search overview
 
Elasticsearch Introduction at BigData meetup
Elasticsearch Introduction at BigData meetupElasticsearch Introduction at BigData meetup
Elasticsearch Introduction at BigData meetup
 
ElasticSearch in action
ElasticSearch in actionElasticSearch in action
ElasticSearch in action
 
Use Cases for Elastic Search Percolator
Use Cases for Elastic Search PercolatorUse Cases for Elastic Search Percolator
Use Cases for Elastic Search Percolator
 
Solr vs. Elasticsearch - Case by Case
Solr vs. Elasticsearch - Case by CaseSolr vs. Elasticsearch - Case by Case
Solr vs. Elasticsearch - Case by Case
 
Elasticsearch Introduction
Elasticsearch IntroductionElasticsearch Introduction
Elasticsearch Introduction
 

Destaque

Elasticsearch Data Analyses
Elasticsearch Data AnalysesElasticsearch Data Analyses
Elasticsearch Data Analyses
Alaa Elhadba
 
Migrating from monolithic rails
Migrating from monolithic railsMigrating from monolithic rails
Migrating from monolithic rails
Danielius Visockas
 
How did you attract/address your audience?
How did you attract/address your audience?How did you attract/address your audience?
How did you attract/address your audience?
Charlotte Power
 
NOSANN IT Scope of Services
NOSANN IT Scope of ServicesNOSANN IT Scope of Services
NOSANN IT Scope of Services
Mahmoud Abdullah
 

Destaque (16)

Elasticsearch Data Analyses
Elasticsearch Data AnalysesElasticsearch Data Analyses
Elasticsearch Data Analyses
 
Elasticsearch Aggregations
Elasticsearch AggregationsElasticsearch Aggregations
Elasticsearch Aggregations
 
What's new in Elasticsearch v5
What's new in Elasticsearch v5What's new in Elasticsearch v5
What's new in Elasticsearch v5
 
Elasticsearch Introduction to Data model, Search & Aggregations
Elasticsearch Introduction to Data model, Search & AggregationsElasticsearch Introduction to Data model, Search & Aggregations
Elasticsearch Introduction to Data model, Search & Aggregations
 
TDC2016POA | Trilha BigData - Respostas em tempo real para perguntas complexa...
TDC2016POA | Trilha BigData - Respostas em tempo real para perguntas complexa...TDC2016POA | Trilha BigData - Respostas em tempo real para perguntas complexa...
TDC2016POA | Trilha BigData - Respostas em tempo real para perguntas complexa...
 
Migrating from monolithic rails
Migrating from monolithic railsMigrating from monolithic rails
Migrating from monolithic rails
 
Influence of micropolar lubricant on bearings performance a review(2)
Influence of micropolar lubricant on bearings performance a review(2)Influence of micropolar lubricant on bearings performance a review(2)
Influence of micropolar lubricant on bearings performance a review(2)
 
Teekait may 16
Teekait may 16Teekait may 16
Teekait may 16
 
Professional dj & dance floor setup
Professional dj & dance floor setupProfessional dj & dance floor setup
Professional dj & dance floor setup
 
GIOVANNI.DALLACQUA.RESUME
GIOVANNI.DALLACQUA.RESUMEGIOVANNI.DALLACQUA.RESUME
GIOVANNI.DALLACQUA.RESUME
 
How did you attract/address your audience?
How did you attract/address your audience?How did you attract/address your audience?
How did you attract/address your audience?
 
NOSANN Profile
NOSANN ProfileNOSANN Profile
NOSANN Profile
 
Norme de-aplicare a Legii 142/1998 privind tichetele de masa
Norme de-aplicare a Legii 142/1998 privind tichetele de masaNorme de-aplicare a Legii 142/1998 privind tichetele de masa
Norme de-aplicare a Legii 142/1998 privind tichetele de masa
 
SUMTI CV
SUMTI CVSUMTI CV
SUMTI CV
 
моє захоплення
моє захопленнямоє захоплення
моє захоплення
 
NOSANN IT Scope of Services
NOSANN IT Scope of ServicesNOSANN IT Scope of Services
NOSANN IT Scope of Services
 

Semelhante a ElasticSearch - Introduction to Aggregations

Hopper Elasticsearch Hackathon
Hopper Elasticsearch HackathonHopper Elasticsearch Hackathon
Hopper Elasticsearch Hackathon
imotov
 
MongoDB Analytics: Learn Aggregation by Example - Exploratory Analytics and V...
MongoDB Analytics: Learn Aggregation by Example - Exploratory Analytics and V...MongoDB Analytics: Learn Aggregation by Example - Exploratory Analytics and V...
MongoDB Analytics: Learn Aggregation by Example - Exploratory Analytics and V...
MongoDB
 

Semelhante a ElasticSearch - Introduction to Aggregations (20)

Hopper Elasticsearch Hackathon
Hopper Elasticsearch HackathonHopper Elasticsearch Hackathon
Hopper Elasticsearch Hackathon
 
Elasticsearch Quick Introduction
Elasticsearch Quick IntroductionElasticsearch Quick Introduction
Elasticsearch Quick Introduction
 
Webinar: Exploring the Aggregation Framework
Webinar: Exploring the Aggregation FrameworkWebinar: Exploring the Aggregation Framework
Webinar: Exploring the Aggregation Framework
 
MongoDB.local DC 2018: Tutorial - Data Analytics with MongoDB
MongoDB.local DC 2018: Tutorial - Data Analytics with MongoDBMongoDB.local DC 2018: Tutorial - Data Analytics with MongoDB
MongoDB.local DC 2018: Tutorial - Data Analytics with MongoDB
 
Elasticsearch: You know, for search! and more!
Elasticsearch: You know, for search! and more!Elasticsearch: You know, for search! and more!
Elasticsearch: You know, for search! and more!
 
Talk MongoDB - Amil
Talk MongoDB - AmilTalk MongoDB - Amil
Talk MongoDB - Amil
 
ELK - What's new and showcases
ELK - What's new and showcasesELK - What's new and showcases
ELK - What's new and showcases
 
Couchbase Tutorial: Big data Open Source Systems: VLDB2018
Couchbase Tutorial: Big data Open Source Systems: VLDB2018Couchbase Tutorial: Big data Open Source Systems: VLDB2018
Couchbase Tutorial: Big data Open Source Systems: VLDB2018
 
Montreal Elasticsearch Meetup
Montreal Elasticsearch MeetupMontreal Elasticsearch Meetup
Montreal Elasticsearch Meetup
 
Mongo db query docuement
Mongo db query docuementMongo db query docuement
Mongo db query docuement
 
How we (Almost) Forgot Lambda Architecture and used Elasticsearch
How we (Almost) Forgot Lambda Architecture and used ElasticsearchHow we (Almost) Forgot Lambda Architecture and used Elasticsearch
How we (Almost) Forgot Lambda Architecture and used Elasticsearch
 
Academy PRO: Elasticsearch Misc
Academy PRO: Elasticsearch MiscAcademy PRO: Elasticsearch Misc
Academy PRO: Elasticsearch Misc
 
Application Development & Database Choices: Postgres Support for non Relation...
Application Development & Database Choices: Postgres Support for non Relation...Application Development & Database Choices: Postgres Support for non Relation...
Application Development & Database Choices: Postgres Support for non Relation...
 
Elasticsearch in 15 minutes
Elasticsearch in 15 minutesElasticsearch in 15 minutes
Elasticsearch in 15 minutes
 
Deep dive into N1QL: SQL for JSON: Internals and power features.
Deep dive into N1QL: SQL for JSON: Internals and power features.Deep dive into N1QL: SQL for JSON: Internals and power features.
Deep dive into N1QL: SQL for JSON: Internals and power features.
 
MongoDB Analytics: Learn Aggregation by Example - Exploratory Analytics and V...
MongoDB Analytics: Learn Aggregation by Example - Exploratory Analytics and V...MongoDB Analytics: Learn Aggregation by Example - Exploratory Analytics and V...
MongoDB Analytics: Learn Aggregation by Example - Exploratory Analytics and V...
 
MongoDB .local Chicago 2019: Best Practices for Working with IoT and Time-ser...
MongoDB .local Chicago 2019: Best Practices for Working with IoT and Time-ser...MongoDB .local Chicago 2019: Best Practices for Working with IoT and Time-ser...
MongoDB .local Chicago 2019: Best Practices for Working with IoT and Time-ser...
 
Making your elastic cluster perform - Jettro Coenradie - Codemotion Amsterdam...
Making your elastic cluster perform - Jettro Coenradie - Codemotion Amsterdam...Making your elastic cluster perform - Jettro Coenradie - Codemotion Amsterdam...
Making your elastic cluster perform - Jettro Coenradie - Codemotion Amsterdam...
 
MongoDB SoCal 2020: Best Practices for Working with IoT and Time-series Data
MongoDB SoCal 2020: Best Practices for Working with IoT and Time-series DataMongoDB SoCal 2020: Best Practices for Working with IoT and Time-series Data
MongoDB SoCal 2020: Best Practices for Working with IoT and Time-series Data
 
Peggy elasticsearch應用
Peggy elasticsearch應用Peggy elasticsearch應用
Peggy elasticsearch應用
 

Mais de enterprisesearchmeetup

Relevancy and Search Quality Analysis - Search Technologies
Relevancy and Search Quality Analysis - Search TechnologiesRelevancy and Search Quality Analysis - Search Technologies
Relevancy and Search Quality Analysis - Search Technologies
enterprisesearchmeetup
 

Mais de enterprisesearchmeetup (6)

Cisco meetup-25 april2017
Cisco meetup-25 april2017Cisco meetup-25 april2017
Cisco meetup-25 april2017
 
Algolia - Hosted Search API
Algolia - Hosted Search API Algolia - Hosted Search API
Algolia - Hosted Search API
 
The Elastic ELK Stack
The Elastic ELK StackThe Elastic ELK Stack
The Elastic ELK Stack
 
Relevancy and Search Quality Analysis - Search Technologies
Relevancy and Search Quality Analysis - Search TechnologiesRelevancy and Search Quality Analysis - Search Technologies
Relevancy and Search Quality Analysis - Search Technologies
 
Scalable Search Analytics
Scalable Search AnalyticsScalable Search Analytics
Scalable Search Analytics
 
Practical Relevance Measurement
Practical Relevance MeasurementPractical Relevance Measurement
Practical Relevance Measurement
 

Último

Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Último (20)

Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 

ElasticSearch - Introduction to Aggregations

  • 1. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission is strictly Introduction to Aggregations
  • 2. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission is strictly facets (elasticsearch < 1.0) facets
  • 3. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission is strictly out-of-the-box facets (elasticsearch < 1.0) • terms • range • histogram / date histogram • filter/query • statistical • geo distance
  • 4. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission is strictly terms facet • Divides documents into buckets based on a value of a selected term • Calculates statistics on some other field of these document for each bucket
  • 5. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission is strictly index of large US cities { "rank": "21", "city": "Boston", "state": "MA", "population2012": "636479", "population2010": "617594", "land_area": "48.277", "density": "12793", "ansi": "619463", "location": { "lat": "42.332", "lon": "71.0202" } }
  • 6. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission is strictly example: terms facet request $ curl -XGET "localhost:9200/test-data/cities/_search?pretty" -d '{ "facets": { "stat1": { "terms_stats": { "key_field": "state", "value_field": "density" } } } }' group by this field calculate stats for this field
  • 7. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission is strictly example: terms facet response "facets" : { "stat1" : { "_type" : "terms_stats", "missing" : 0, "terms" : [ { "term" : "CA", "count" : 69, "total_count" : 69, "min" : 1442.0, "max" : 17179.0, "total" : 383545.0, "mean" : 5558.623188405797 }, { "term" : "TX", "count" : 32, "total_count" : 32, "min" : 1096.0, "max" : 3974.0, "total" : 79892.0, "mean" : 2496.625 }, { "term" : "FL", "count" : 20, "total_count" : 20, "min" : 1100.0, "max" : 11136.0, "total" : 80132.0, group by field stats
  • 8. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission is strictly example: range facet request curl -XGET "localhost:9200/test-data/cities/_search?pretty" -d '{ "facets": { "population_ranges": { "histogram": { "key_field": "population2012", "value_field": "density", "interval": 500000 } } } }' group by this field calculate stats by this field
  • 9. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission is strictly example: terms facet response "facets" : { "population_ranges" : { "_type" : "histogram", "entries" : [ { "key" : 0, "count" : 255, "min" : 171.0, "max" : 17346.0, "total" : 980306.0, "total_count" : 252, "mean" : 3890.1031746031745 }, { "key" : 500000, "count" : 25, "min" : 956.0, "max" : 17179.0, "total" : 116597.0, "total_count" : 25, "mean" : 4663.88 }, { "key" : 1000000, "count" : 4, "min" : 2798.0, "max" : 4020.0, "total" : 13216.0, "total_count" : 4, "mean" : 3304.0 group by field (population) stats (density)
  • 10. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission is strictly nt an average density by population histogram
  • 11. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission is strictly aggregations Buckets Calculators
  • 12. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission is strictly aggregations = buckets + calculators CA TX MA CO AZ "facets" : { "population_ranges" : { "_type" : "histogram", "entries" : [ { "key" : 0, "count" : 255, "min" : 171.0, "max" : 17346.0, "total" : 980306.0, "total_count" : 252, "mean" : 3890.1031746031745 }, { "key" : 500000, "count" : 25, "min" : 956.0, "max" : 17179.0, "total" : 116597.0, "total_count" : 25, "mean" : 4663.88 }, { "key" : 1000000, "count" : 4, "min" : 2798.0, "max" : 4020.0, "total" : 13216.0, "total_count" : 4, "mean" : 3304.0 }, {
  • 13. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission is strictly aggregations = buckets + calculators CA TX MA CO AZ
  • 14. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission is strictly example: density by state aggregation $ curl -XGET "localhost:9200/test-data/cities/_search?pretty" -d '{ "aggs" : { "mean_density_by_state" : { "terms" : { "field" : "state" }, "aggs": { "mean_density": { "avg" : { "field" : "density" } } } } } }' group by this field calculate stats for this field
  • 15. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission is strictly aggregation response "aggregations" : { "mean_density_by_state" : { "terms" : [ { "term" : "CA", "doc_count" : 69, "mean_density" : { "value" : 5558.623188405797 } }, { "term" : "TX", "doc_count" : 32, "mean_density" : { "value" : 2496.625 } }, { "term" : "FL", "doc_count" : 20, "mean_density" : { "value" : 4006.6 } }, { "term" : "CO", "doc_count" : 11, "mean_density" : { "value" : 2944.4 } }, { group by state density stats
  • 16. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission is strictly example: density by population aggregation $ curl -XGET "localhost:9200/test-data/cities/_search?pretty" -d '{ "aggs" : { "mean_density_by_population" : { "histogram" : { "field" : "population2012", "interval": 500000 }, "aggs": { "mean_density": { "avg" : { "field" : "density" } } } } } }' group by population calculate stats density
  • 17. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission is strictly aggregation response "aggregations" : { "mean_density_by_population" : [ { "key" : 0, "doc_count" : 255, "mean_density" : { "value" : 3890.1031746031745 } }, { "key" : 500000, "doc_count" : 25, "mean_density" : { "value" : 4663.88 } }, { "key" : 1000000, "doc_count" : 4, "mean_density" : { "value" : 3304.0 } }, { "key" : 1500000, "doc_count" : 1, "mean_density" : { "value" : 11379.0 } group by population density stats
  • 18. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission is strictly example: density by population by state $ curl -XGET "localhost:9200/test-data/cities/_search?pretty" -d '{ "aggs" : { "mean_density_by_population_by_state": { "terms" : { "field" : "state" }, "aggs": { "mean_density_by_population" : { "histogram" : { "field" : "population2012", "interval": 500000 }, "aggs": { "mean_density": { "avg" : { "field" : "density" } } } } } } } }' group by population calculate stats on density group by state
  • 19. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission is strictly aggregation response"aggregations" : { "mean_density_by_population_by_state" : { "terms" : [ { "term" : "CA", "doc_count" : 69, "mean_density_by_population" : [ { "key" : 0, "doc_count" : 64, "mean_density" : { "value" : 5382.453125 } }, { "key" : 500000, "doc_count" : 3, "mean_density" : { "value" : 8985.333333333334 } }, { "key" : 1000000, "doc_count" : 1, "mean_density" : { "value" : 4020.0 } }, { "key" : 3500000, "doc_count" : 1, "mean_density" : { "value" : 8092.0 } } ] }, { "term" : "TX", "doc_count" : 32, "mean_density_by_population" : [ { "key" : 0, "doc_count" : 26, "mean_density" : { "value" : 2408.3076923076924 group by population stats on density group by state
  • 20. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission is strictly out-of-the-box aggregation calculators (elasticsearch >= 1.0) • avg • min • max • sum • count • stats • extended stats
  • 21. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission is strictly out-of-the-box aggregation bucketizers (elasticsearch >= 1.0) • global • filter • missing • terms • range • date range • ip range • histogram • date histogram • geo distance • nested
  • 22. Copyright Elasticsearch 2013. Copying, publishing and/or distributing without written permission is strictly aggregations 2.0 (aka bucket reducers) (elasticsearch 2.0) apply arbitrary functions on buckets • first derivative • second derivative • exponential weighted moving average • outlier detection