How to Use Aggregations in Elasticsearch: Everything You Need to Know
Вставка
- Опубліковано 29 вер 2023
- 🔴 Perks: www.youtube.com/@EngineeringD...
🔴 Instagram: / thevipulvats
🔴 GitHub: github.com/thevipulvats
🔴 Twitter: / thevipulvats
🔴 LeetCode: leetcode.com/thevipulvats
🔴 LinkedIn: / thevipulvats
🔴 Discord: / discord
Welcome to this comprehensive guide on Aggregations in Elasticsearch! 😊 In this tutorial, we'll dive deep into:
- 📊 **Basics of Aggregations**: Understand the foundation and how they work in Elasticsearch.
- 🛠 *Types of Aggregations*: Bucket, Metric, Matrix, and Pipeline aggregations explained.
- 📈 *Use Cases*: Real-world examples of when and how to use different aggregations.
- 💡 *Tips & Tricks*: Optimizing your aggregations for better performance and insights.
Whether you're a beginner or have some experience, this video is designed to provide value for everyone. Don't forget to like, share, and subscribe for more tutorials!
You can use this data to play with. This is not exactly the same but will do the work.
POST _bulk
{ "index" : { "_index" : "movies", "_type" : "_doc", "_id" : "1" } }
{ "name": "Inception", "actors": ["Leonardo DiCaprio", "Joseph Gordon-Levitt", "Ellen Page"], "director": "Christopher Nolan", "rating": 8.8, "genre": "Sci-Fi", "budget": 160000000, "box_office": 828300000, "length": 148, "release_year": 2010 }
{ "index" : { "_index" : "movies", "_type" : "_doc", "_id" : "2" } }
{ "name": "The Shawshank Redemption", "actors": ["Tim Robbins", "Morgan Freeman"], "director": "Frank Darabont", "rating": 9.3, "genre": "Drama", "budget": 25000000, "box_office": 28699976, "length": 142, "release_year": 1994 }
{ "index" : { "_index" : "movies", "_type" : "_doc", "_id" : "3" } }
{ "name": "The Godfather", "actors": ["Marlon Brando", "Al Pacino", "James Caan"], "director": "Francis Ford Coppola", "rating": 9.2, "genre": "Crime", "budget": 6000000, "box_office": 286000000, "length": 175, "release_year": 1972 }
{ "index" : { "_index" : "movies", "_type" : "_doc", "_id" : "4" } }
{ "name": "The Dark Knight", "actors": ["Christian Bale", "Heath Ledger", "Aaron Eckhart"], "director": "Christopher Nolan", "rating": 9.0, "genre": "Action", "budget": 185000000, "box_office": 1004558444, "length": 152, "release_year": 2008 }
{ "index" : { "_index" : "movies", "_type" : "_doc", "_id" : "5" } }
{ "name": "Pulp Fiction", "actors": ["John Travolta", "Uma Thurman", "Samuel L. Jackson"], "director": "Quentin Tarantino", "rating": 8.9, "genre": "Crime", "budget": 8000000, "box_office": 213928762, "length": 154, "release_year": 1994 }
{ "index" : { "_index" : "movies", "_type" : "_doc", "_id" : "6" } }
{ "name": "Schindler's List", "actors": ["Liam Neeson", "Ben Kingsley", "Ralph Fiennes"], "director": "Steven Spielberg", "rating": 8.9, "genre": "Biography", "budget": 22000000, "box_office": 321306305, "length": 195, "release_year": 1993 }
{ "index" : { "_index" : "movies", "_type" : "_doc", "_id" : "7" } }
{ "name": "Forrest Gump", "actors": ["Tom Hanks", "Robin Wright", "Gary Sinise"], "director": "Robert Zemeckis", "rating": 8.8, "genre": "Romance", "budget": 55000000, "box_office": 677387716, "length": 142, "release_year": 1994 }
{ "index" : { "_index" : "movies", "_type" : "_doc", "_id" : "8" } }
{ "name": "The Lord of the Rings: The Return of the King", "actors": ["Elijah Wood", "Viggo Mortensen", "Ian McKellen"], "director": "Peter Jackson", "rating": 8.9, "genre": "Fantasy", "budget": 94000000, "box_office": 1141403341, "length": 201, "release_year": 2003 }
{ "index" : { "_index" : "movies", "_type" : "_doc", "_id" : "9" } }
{ "name": "Fight Club", "actors": ["Brad Pitt", "Edward Norton", "Meat Loaf"], "director": "David Fincher", "rating": 8.8, "genre": "Drama", "budget": 63000000, "box_office": 100853753, "length": 139, "release_year": 1999 }
{ "index" : { "_index" : "movies", "_type" : "_doc", "_id" : "10" } }
{ "name": "The Matrix", "actors": ["Keanu Reeves", "Laurence Fishburne", "Carrie-Anne Moss"], "director": "Lana Wachowski", "rating": 8.7, "genre": "Sci-Fi", "budget": 63000000, "box_office": 463517383, "length": 136, "release_year": 1999 }
{ "index" : { "_index" : "movies", "_type" : "_doc", "_id" : "11" } }
{ "name": "Gladiator", "actors": ["Russell Crowe", "Joaquin Phoenix", "Connie Nielsen"], "director": "Ridley Scott", "rating": 8.5, "genre": "Action", "budget": 103000000, "box_office": 457640427, "length": 155, "release_year": 2000 }
for anyone trying to use this to create the index through dev tools; remove the type parameter as it has been removed by elasticsearch
This should work
POST _bulk
{ "index" : { "_index" : "movies", "_id" : "1" } }
{ "name": "Inception", "actors": ["Leonardo DiCaprio", "Joseph Gordon-Levitt", "Ellen Page"], "director": "Christopher Nolan", "rating": 8.8, "genre": "Sci-Fi", "budget": 160000000, "box_office": 828300000, "length": 148, "release_year": 2010 }
{ "index" : { "_index" : "movies", "_id" : "2" } }
{ "name": "The Shawshank Redemption", "actors": ["Tim Robbins", "Morgan Freeman"], "director": "Frank Darabont", "rating": 9.3, "genre": "Drama", "budget": 25000000, "box_office": 28699976, "length": 142, "release_year": 1994 }
{ "index" : { "_index" : "movies", "_id" : "3" } }
{ "name": "The Godfather", "actors": ["Marlon Brando", "Al Pacino", "James Caan"], "director": "Francis Ford Coppola", "rating": 9.2, "genre": "Crime", "budget": 6000000, "box_office": 286000000, "length": 175, "release_year": 1972 }
{ "index" : { "_index" : "movies", "_id" : "4" } }
{ "name": "The Dark Knight", "actors": ["Christian Bale", "Heath Ledger", "Aaron Eckhart"], "director": "Christopher Nolan", "rating": 9.0, "genre": "Action", "budget": 185000000, "box_office": 1004558444, "length": 152, "release_year": 2008 }
{ "index" : { "_index" : "movies", "_id" : "5" } }
{ "name": "Pulp Fiction", "actors": ["John Travolta", "Uma Thurman", "Samuel L. Jackson"], "director": "Quentin Tarantino", "rating": 8.9, "genre": "Crime", "budget": 8000000, "box_office": 213928762, "length": 154, "release_year": 1994 }
{ "index" : { "_index" : "movies", "_id" : "6" } }
{ "name": "Schindler's List", "actors": ["Liam Neeson", "Ben Kingsley", "Ralph Fiennes"], "director": "Steven Spielberg", "rating": 8.9, "genre": "Biography", "budget": 22000000, "box_office": 321306305, "length": 195, "release_year": 1993 }
{ "index" : { "_index" : "movies", "_id" : "7" } }
{ "name": "Forrest Gump", "actors": ["Tom Hanks", "Robin Wright", "Gary Sinise"], "director": "Robert Zemeckis", "rating": 8.8, "genre": "Romance", "budget": 55000000, "box_office": 677387716, "length": 142, "release_year": 1994 }
{ "index" : { "_index" : "movies", "_id" : "8" } }
{ "name": "The Lord of the Rings: The Return of the King", "actors": ["Elijah Wood", "Viggo Mortensen", "Ian McKellen"], "director": "Peter Jackson", "rating": 8.9, "genre": "Fantasy", "budget": 94000000, "box_office": 1141403341, "length": 201, "release_year": 2003 }
{ "index" : { "_index" : "movies", "_id" : "9" } }
{ "name": "Fight Club", "actors": ["Brad Pitt", "Edward Norton", "Meat Loaf"], "director": "David Fincher", "rating": 8.8, "genre": "Drama", "budget": 63000000, "box_office": 100853753, "length": 139, "release_year": 1999 }
{ "index" : { "_index" : "movies", "_id" : "10" } }
{ "name": "The Matrix", "actors": ["Keanu Reeves", "Laurence Fishburne", "Carrie-Anne Moss"], "director": "Lana Wachowski", "rating": 8.7, "genre": "Sci-Fi", "budget": 63000000, "box_office": 463517383, "length": 136, "release_year": 1999 }
{ "index" : { "_index" : "movies", "_id" : "11" } }
{ "name": "Gladiator", "actors": ["Russell Crowe", "Joaquin Phoenix", "Connie Nielsen"], "director": "Ridley Scott", "rating": 8.5, "genre": "Action", "budget": 103000000, "box_office": 457640427, "length": 155, "release_year": 2000 }
the way you explain is soo cool!
HI Vipul,
Can we get exam practice question set, how questions may asked in Elastic Certified Engineer and also small session on ILM policy.
Hi Vipul,
Can you please share practice question set as per Elastic Certified Engineer exam.
Can we able to substract two fields values. Using metric aggregation and buckets aggregation in dashboard panel? The subtraction values should display in separate column in panel.
Hi, i have one doubt that is how to include text fields in aggregate query in elasticsearch version 1
Eiter have a sub type as keyword. in the mapping. Another option is to create a runtime_mapping in query time (takes more memory)
please do a video on pipeline
nyc explanation
this video is better than openAI
Sir, please create a video on the topic of 'pipeline aggregations'
superb
Thanks for liking
sir make a video for route
pipeline?
pipeline
Where is the Bulk API?
see previous videos..it's in the same playlist
@@EngineeringDigest Bhai, I did not find the movies dataset that you have used to explain in this video. Can you please share link to the dataset and api to upload it :)
check pinned comment@@aniketsahare6480
@@EngineeringDigest Thanks a lot 🤝
Can we make use of bucket selector after aggregation