SlideShare a Scribd company logo
1 of 13
Elasticsearch
Getting Started Part 3
Aggregations
Suyog Kale
Kloojj.com
Kloojj.com
Suyog Dilip Kale
Technology Evangelist
Chief Architect
www.kloojj.com
Organiser
Pune Developer’s Community
www.meetup.com/Pune-Developers-Community
http://www.punedevscommunity.in/
Kloojj.com
● Aggregations
○ What is aggregations in Elasticsearch?
○ Metrics aggregations
■ Avg aggregation
■ Cardinality aggregation
■ Extended stats aggregation
■ Min & Max aggregation
■ Sum aggregation
○ Bucket aggregations
○ Nested Bucket aggregations
Kloojj.com
● Read-What is aggregations in Elasticsearch
○ Aggregations helps provide aggregated data based on a search query.
○ It can be composed in order to build complex summaries of the data.
○ There are many different types of aggregations, each with its own
purpose and output.
○ Elasticsearch aggregations let you zoom out to explore trends and
patterns in your data.
○ What if your ecommerce portal has billions of user visits and you
want drill down it by country, states and then cities? What if you want
to see avg user age groups OR gender wise product interests ? What if
you want calculate daily, weekly or monthly sales ?
○ Everything is much easy with Elasticsearch aggregations
Kloojj.com
● Read-Metrics aggregations
○ Metrics Aggregations are used to compute metrics over set of
documents. Numeric matrices are either single-valued like average
aggregation or multi-valued like stats.
○ Avg aggregations: to get the average of any numeric field present in
the aggregated documents, see below example:
GET /website/user/_search
{
"aggs": {
"avg_score": {
"avg": {
"field": "score"
}
}
}
}
Kloojj.com
● Read-Metrics aggregations
○ Cardinality aggregations: to get the count of distinct values of a
particular field, see below example:
GET /website/user/_search
{
"aggs": {
"cardinality_cname": {
"cardinality": {
"field": "cname"
}
}
}
}
○ This will give you distinct country name count.
Kloojj.com
● Read-Metrics aggregations
○ Extended stats aggregations: it generates all the statistics about a
specific numerical field in aggregated documents, for example:
GET /website/user/_search
{
"aggs": {
"stats_score": {
"stats": {
"field": "score"
}
}
}
}
○ It will return all statistics on score field like total records,minimum,
maximum, average and total sum value.
Kloojj.com
● Read-Metrics aggregations
○ Min & Max aggregations: These aggregations can be used to find the
max or min value of a specific numeric field in aggregated documents.
For example below one returns max value from score field:
GET /website/user/_search
{
"aggs": {
"max_score": {
"max": {
"field": "score"
}
}
}
}
Kloojj.com
● Read-Metrics aggregations
○ Sum aggregation: This aggregation calculates the sum of a specific
numeric field in aggregated documents. For example:
GET /website/user/_search
{
"aggs": {
"total_score": {
"sum": {
"field": "score"
}
}
}
}
○ This returns the total of score value
Kloojj.com
● Read-Bucket aggregations
○ These aggregations contain many buckets for different types of
aggregations having a criterion, which determines whether a
document belongs to that bucket or not.
○ There are many other special bucket aggregations, those are −
● Date Histogram Aggregation
● Date Range Aggregation
● Filter Aggregation
● Filters Aggregation
● Geo Distance Aggregation
● GeoHash grid Aggregation
● Global Aggregation
● Histogram Aggregation
● IPv4 Range Aggregation
● Missing Aggregation
● Nested Aggregation
● Range Aggregation
● Reverse nested Aggregation
● Sampler Aggregation
● Significant Terms Aggregation
● Terms Aggregation
Kloojj.com
● Read-Bucket aggregations
○ Let’s try term bucket aggregation
GET /website/user/_search
{
"aggs": {
"by_cname": {
"terms": {
"field": "cname"
}
}
}
}
○ If you see the result it will return the document counts for each
country found in aggregated documents
Kloojj.com
● Read-Nested Bucket aggregations
○ To drill down the aggregation results, it is best way to nest them, for
example, if you want to get counts against each action by country try
below query:
GET /website/user/_search
{
"aggs": {
"by_cname": {
"terms": {
"field": "cname"
},
"aggs": {
"by_action": {
"terms": {
"field": "action"
}
}
}
}
}
}
Kloojj.com
Suyog Dilip Kale
Email suyog.kale@gmail.com
Twitter @suyog_kale
Thank You !!!

More Related Content

What's hot

Exploring Large Chemical Data Sets
Exploring Large Chemical Data SetsExploring Large Chemical Data Sets
Exploring Large Chemical Data Setskylelutz
 
Let's downscale the semantic web !
Let's downscale the semantic web !Let's downscale the semantic web !
Let's downscale the semantic web !Christophe Guéret
 
Exposing the data from NARCIS with VIVO
Exposing the data from NARCIS with VIVOExposing the data from NARCIS with VIVO
Exposing the data from NARCIS with VIVOChristophe Guéret
 
Publishing XBRL as Linked Open Data
Publishing XBRL as Linked Open DataPublishing XBRL as Linked Open Data
Publishing XBRL as Linked Open DataRoberto García
 
PhD Projects in Green Cloud Computing Research Guidance
PhD Projects in Green Cloud Computing Research GuidancePhD Projects in Green Cloud Computing Research Guidance
PhD Projects in Green Cloud Computing Research GuidancePhD Services
 
Big data Europe: concept, platform and pilots
Big data Europe: concept, platform and pilotsBig data Europe: concept, platform and pilots
Big data Europe: concept, platform and pilotsBigData_Europe
 

What's hot (11)

Exploring Large Chemical Data Sets
Exploring Large Chemical Data SetsExploring Large Chemical Data Sets
Exploring Large Chemical Data Sets
 
Let's downscale the semantic web !
Let's downscale the semantic web !Let's downscale the semantic web !
Let's downscale the semantic web !
 
Exposing the data from NARCIS with VIVO
Exposing the data from NARCIS with VIVOExposing the data from NARCIS with VIVO
Exposing the data from NARCIS with VIVO
 
Publishing XBRL as Linked Open Data
Publishing XBRL as Linked Open DataPublishing XBRL as Linked Open Data
Publishing XBRL as Linked Open Data
 
computer full forms
computer full formscomputer full forms
computer full forms
 
Data Skipping Technology
Data Skipping TechnologyData Skipping Technology
Data Skipping Technology
 
PhD Projects in Green Cloud Computing Research Guidance
PhD Projects in Green Cloud Computing Research GuidancePhD Projects in Green Cloud Computing Research Guidance
PhD Projects in Green Cloud Computing Research Guidance
 
First Step in NoSql
First Step in NoSqlFirst Step in NoSql
First Step in NoSql
 
Big data Europe: concept, platform and pilots
Big data Europe: concept, platform and pilotsBig data Europe: concept, platform and pilots
Big data Europe: concept, platform and pilots
 
Ajax
Ajax Ajax
Ajax
 
DMA Ignite Night - Status DMA
DMA Ignite Night - Status DMADMA Ignite Night - Status DMA
DMA Ignite Night - Status DMA
 

Similar to Elasticsearch: Getting Started Part 3 Aggregations

Elasticsearch for Data Analytics
Elasticsearch for Data AnalyticsElasticsearch for Data Analytics
Elasticsearch for Data AnalyticsFelipe
 
All about aggregations
All about aggregationsAll about aggregations
All about aggregationsFan Robbin
 
Big Query - Women Techmarkers (Ukraine - March 2014)
Big Query - Women Techmarkers (Ukraine - March 2014)Big Query - Women Techmarkers (Ukraine - March 2014)
Big Query - Women Techmarkers (Ukraine - March 2014)Ido Green
 
Logging and ranting / Vytis Valentinavičius (Lamoda)
Logging and ranting / Vytis Valentinavičius (Lamoda)Logging and ranting / Vytis Valentinavičius (Lamoda)
Logging and ranting / Vytis Valentinavičius (Lamoda)Ontico
 
Precog & MongoDB User Group: Skyrocket Your Analytics
Precog & MongoDB User Group: Skyrocket Your Analytics Precog & MongoDB User Group: Skyrocket Your Analytics
Precog & MongoDB User Group: Skyrocket Your Analytics MongoDB
 
SFScon15 - Peter Moser: "The path of a query - POstgreSQL internals"
SFScon15 - Peter Moser: "The path of a query - POstgreSQL internals"SFScon15 - Peter Moser: "The path of a query - POstgreSQL internals"
SFScon15 - Peter Moser: "The path of a query - POstgreSQL internals"South Tyrol Free Software Conference
 
OSMC 2014: Introduction into collectd | Florian Foster
OSMC 2014: Introduction into collectd | Florian FosterOSMC 2014: Introduction into collectd | Florian Foster
OSMC 2014: Introduction into collectd | Florian FosterNETWAYS
 
Building an Observability platform with ClickHouse
Building an Observability platform with ClickHouseBuilding an Observability platform with ClickHouse
Building an Observability platform with ClickHouseAltinity Ltd
 
PCU@RISE 2017 - Building a thesaurus for product search
PCU@RISE 2017 - Building a thesaurus for product searchPCU@RISE 2017 - Building a thesaurus for product search
PCU@RISE 2017 - Building a thesaurus for product searchPCU Consortium
 
PCU@RISE 2017 - Building a thesaurus for product search
PCU@RISE 2017 - Building a thesaurus for product searchPCU@RISE 2017 - Building a thesaurus for product search
PCU@RISE 2017 - Building a thesaurus for product searchMarc Dutoo
 
Elasticsearch for Data Engineers
Elasticsearch for Data EngineersElasticsearch for Data Engineers
Elasticsearch for Data EngineersDuy Do
 
Smart solutions for productivity gain IQA conference 2017
Smart solutions for productivity gain   IQA conference 2017Smart solutions for productivity gain   IQA conference 2017
Smart solutions for productivity gain IQA conference 2017Steve Franklin
 
Redis Day TLV 2018 - RediSearch Aggregations
Redis Day TLV 2018 - RediSearch AggregationsRedis Day TLV 2018 - RediSearch Aggregations
Redis Day TLV 2018 - RediSearch AggregationsRedis Labs
 
MongoDB World 2016 : Advanced Aggregation
MongoDB World 2016 : Advanced AggregationMongoDB World 2016 : Advanced Aggregation
MongoDB World 2016 : Advanced AggregationJoe Drumgoole
 
MongoDB - Aggregation Pipeline
MongoDB - Aggregation PipelineMongoDB - Aggregation Pipeline
MongoDB - Aggregation PipelineJason Terpko
 
OSMC 2018 | Learnings, patterns and Uber’s metrics platform M3, open sourced ...
OSMC 2018 | Learnings, patterns and Uber’s metrics platform M3, open sourced ...OSMC 2018 | Learnings, patterns and Uber’s metrics platform M3, open sourced ...
OSMC 2018 | Learnings, patterns and Uber’s metrics platform M3, open sourced ...NETWAYS
 
Big Query Basics
Big Query BasicsBig Query Basics
Big Query BasicsIdo Green
 
Web Traffic Time Series Forecasting
Web Traffic  Time Series ForecastingWeb Traffic  Time Series Forecasting
Web Traffic Time Series ForecastingBillTubbs
 

Similar to Elasticsearch: Getting Started Part 3 Aggregations (20)

Elasticsearch for Data Analytics
Elasticsearch for Data AnalyticsElasticsearch for Data Analytics
Elasticsearch for Data Analytics
 
All about aggregations
All about aggregationsAll about aggregations
All about aggregations
 
Big Query - Women Techmarkers (Ukraine - March 2014)
Big Query - Women Techmarkers (Ukraine - March 2014)Big Query - Women Techmarkers (Ukraine - March 2014)
Big Query - Women Techmarkers (Ukraine - March 2014)
 
Logging and ranting / Vytis Valentinavičius (Lamoda)
Logging and ranting / Vytis Valentinavičius (Lamoda)Logging and ranting / Vytis Valentinavičius (Lamoda)
Logging and ranting / Vytis Valentinavičius (Lamoda)
 
Precog & MongoDB User Group: Skyrocket Your Analytics
Precog & MongoDB User Group: Skyrocket Your Analytics Precog & MongoDB User Group: Skyrocket Your Analytics
Precog & MongoDB User Group: Skyrocket Your Analytics
 
SFScon15 - Peter Moser: "The path of a query - POstgreSQL internals"
SFScon15 - Peter Moser: "The path of a query - POstgreSQL internals"SFScon15 - Peter Moser: "The path of a query - POstgreSQL internals"
SFScon15 - Peter Moser: "The path of a query - POstgreSQL internals"
 
Elasticsearch speed is key
Elasticsearch speed is keyElasticsearch speed is key
Elasticsearch speed is key
 
OSMC 2014: Introduction into collectd | Florian Foster
OSMC 2014: Introduction into collectd | Florian FosterOSMC 2014: Introduction into collectd | Florian Foster
OSMC 2014: Introduction into collectd | Florian Foster
 
Building an Observability platform with ClickHouse
Building an Observability platform with ClickHouseBuilding an Observability platform with ClickHouse
Building an Observability platform with ClickHouse
 
PCU@RISE 2017 - Building a thesaurus for product search
PCU@RISE 2017 - Building a thesaurus for product searchPCU@RISE 2017 - Building a thesaurus for product search
PCU@RISE 2017 - Building a thesaurus for product search
 
Nosql part3
Nosql part3Nosql part3
Nosql part3
 
PCU@RISE 2017 - Building a thesaurus for product search
PCU@RISE 2017 - Building a thesaurus for product searchPCU@RISE 2017 - Building a thesaurus for product search
PCU@RISE 2017 - Building a thesaurus for product search
 
Elasticsearch for Data Engineers
Elasticsearch for Data EngineersElasticsearch for Data Engineers
Elasticsearch for Data Engineers
 
Smart solutions for productivity gain IQA conference 2017
Smart solutions for productivity gain   IQA conference 2017Smart solutions for productivity gain   IQA conference 2017
Smart solutions for productivity gain IQA conference 2017
 
Redis Day TLV 2018 - RediSearch Aggregations
Redis Day TLV 2018 - RediSearch AggregationsRedis Day TLV 2018 - RediSearch Aggregations
Redis Day TLV 2018 - RediSearch Aggregations
 
MongoDB World 2016 : Advanced Aggregation
MongoDB World 2016 : Advanced AggregationMongoDB World 2016 : Advanced Aggregation
MongoDB World 2016 : Advanced Aggregation
 
MongoDB - Aggregation Pipeline
MongoDB - Aggregation PipelineMongoDB - Aggregation Pipeline
MongoDB - Aggregation Pipeline
 
OSMC 2018 | Learnings, patterns and Uber’s metrics platform M3, open sourced ...
OSMC 2018 | Learnings, patterns and Uber’s metrics platform M3, open sourced ...OSMC 2018 | Learnings, patterns and Uber’s metrics platform M3, open sourced ...
OSMC 2018 | Learnings, patterns and Uber’s metrics platform M3, open sourced ...
 
Big Query Basics
Big Query BasicsBig Query Basics
Big Query Basics
 
Web Traffic Time Series Forecasting
Web Traffic  Time Series ForecastingWeb Traffic  Time Series Forecasting
Web Traffic Time Series Forecasting
 

Recently uploaded

Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsPrecisely
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 

Recently uploaded (20)

Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power Systems
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 

Elasticsearch: Getting Started Part 3 Aggregations

  • 1. Elasticsearch Getting Started Part 3 Aggregations Suyog Kale Kloojj.com
  • 2. Kloojj.com Suyog Dilip Kale Technology Evangelist Chief Architect www.kloojj.com Organiser Pune Developer’s Community www.meetup.com/Pune-Developers-Community http://www.punedevscommunity.in/
  • 3. Kloojj.com ● Aggregations ○ What is aggregations in Elasticsearch? ○ Metrics aggregations ■ Avg aggregation ■ Cardinality aggregation ■ Extended stats aggregation ■ Min & Max aggregation ■ Sum aggregation ○ Bucket aggregations ○ Nested Bucket aggregations
  • 4. Kloojj.com ● Read-What is aggregations in Elasticsearch ○ Aggregations helps provide aggregated data based on a search query. ○ It can be composed in order to build complex summaries of the data. ○ There are many different types of aggregations, each with its own purpose and output. ○ Elasticsearch aggregations let you zoom out to explore trends and patterns in your data. ○ What if your ecommerce portal has billions of user visits and you want drill down it by country, states and then cities? What if you want to see avg user age groups OR gender wise product interests ? What if you want calculate daily, weekly or monthly sales ? ○ Everything is much easy with Elasticsearch aggregations
  • 5. Kloojj.com ● Read-Metrics aggregations ○ Metrics Aggregations are used to compute metrics over set of documents. Numeric matrices are either single-valued like average aggregation or multi-valued like stats. ○ Avg aggregations: to get the average of any numeric field present in the aggregated documents, see below example: GET /website/user/_search { "aggs": { "avg_score": { "avg": { "field": "score" } } } }
  • 6. Kloojj.com ● Read-Metrics aggregations ○ Cardinality aggregations: to get the count of distinct values of a particular field, see below example: GET /website/user/_search { "aggs": { "cardinality_cname": { "cardinality": { "field": "cname" } } } } ○ This will give you distinct country name count.
  • 7. Kloojj.com ● Read-Metrics aggregations ○ Extended stats aggregations: it generates all the statistics about a specific numerical field in aggregated documents, for example: GET /website/user/_search { "aggs": { "stats_score": { "stats": { "field": "score" } } } } ○ It will return all statistics on score field like total records,minimum, maximum, average and total sum value.
  • 8. Kloojj.com ● Read-Metrics aggregations ○ Min & Max aggregations: These aggregations can be used to find the max or min value of a specific numeric field in aggregated documents. For example below one returns max value from score field: GET /website/user/_search { "aggs": { "max_score": { "max": { "field": "score" } } } }
  • 9. Kloojj.com ● Read-Metrics aggregations ○ Sum aggregation: This aggregation calculates the sum of a specific numeric field in aggregated documents. For example: GET /website/user/_search { "aggs": { "total_score": { "sum": { "field": "score" } } } } ○ This returns the total of score value
  • 10. Kloojj.com ● Read-Bucket aggregations ○ These aggregations contain many buckets for different types of aggregations having a criterion, which determines whether a document belongs to that bucket or not. ○ There are many other special bucket aggregations, those are − ● Date Histogram Aggregation ● Date Range Aggregation ● Filter Aggregation ● Filters Aggregation ● Geo Distance Aggregation ● GeoHash grid Aggregation ● Global Aggregation ● Histogram Aggregation ● IPv4 Range Aggregation ● Missing Aggregation ● Nested Aggregation ● Range Aggregation ● Reverse nested Aggregation ● Sampler Aggregation ● Significant Terms Aggregation ● Terms Aggregation
  • 11. Kloojj.com ● Read-Bucket aggregations ○ Let’s try term bucket aggregation GET /website/user/_search { "aggs": { "by_cname": { "terms": { "field": "cname" } } } } ○ If you see the result it will return the document counts for each country found in aggregated documents
  • 12. Kloojj.com ● Read-Nested Bucket aggregations ○ To drill down the aggregation results, it is best way to nest them, for example, if you want to get counts against each action by country try below query: GET /website/user/_search { "aggs": { "by_cname": { "terms": { "field": "cname" }, "aggs": { "by_action": { "terms": { "field": "action" } } } } } }
  • 13. Kloojj.com Suyog Dilip Kale Email suyog.kale@gmail.com Twitter @suyog_kale Thank You !!!