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!

КОМЕНТАРІ • 24

  • @EngineeringDigest
    @EngineeringDigest  8 місяців тому +2

    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 }

    • @Risky_Bit
      @Risky_Bit 2 місяці тому

      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 }

  • @neeleshaggarwal1832
    @neeleshaggarwal1832 2 дні тому

    the way you explain is soo cool!

  • @HemantP-s8x
    @HemantP-s8x 20 днів тому

    HI Vipul,
    Can we get exam practice question set, how questions may asked in Elastic Certified Engineer and also small session on ILM policy.

  • @HemantP-s8x
    @HemantP-s8x 20 днів тому

    Hi Vipul,
    Can you please share practice question set as per Elastic Certified Engineer exam.

  • @brundhavanip1818
    @brundhavanip1818 7 місяців тому

    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.

  • @ajithshylin3159
    @ajithshylin3159 7 місяців тому

    Hi, i have one doubt that is how to include text fields in aggregate query in elasticsearch version 1

    • @emailshe
      @emailshe Місяць тому

      Eiter have a sub type as keyword. in the mapping. Another option is to create a runtime_mapping in query time (takes more memory)

  • @ashishparida4029
    @ashishparida4029 8 місяців тому

    please do a video on pipeline

  • @manannagpal2822
    @manannagpal2822 2 місяці тому

    nyc explanation

  • @samarthgamingstudio571
    @samarthgamingstudio571 7 місяців тому

    this video is better than openAI

  • @SanaSaleemMalik5
    @SanaSaleemMalik5 4 місяці тому

    Sir, please create a video on the topic of 'pipeline aggregations'

  • @user-rg4lc7hi5d
    @user-rg4lc7hi5d 9 місяців тому

    superb

  • @user-nd9tf4ys7f
    @user-nd9tf4ys7f 4 місяці тому

    sir make a video for route

  • @user-dj5df7hv6p
    @user-dj5df7hv6p 5 місяців тому

    pipeline?

  • @user-dj5df7hv6p
    @user-dj5df7hv6p 6 місяців тому

    pipeline

  • @itspremium
    @itspremium 9 місяців тому

    Where is the Bulk API?

    • @EngineeringDigest
      @EngineeringDigest  9 місяців тому

      see previous videos..it's in the same playlist

    • @aniketsahare6480
      @aniketsahare6480 8 місяців тому

      @@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 :)

    • @EngineeringDigest
      @EngineeringDigest  8 місяців тому

      check pinned comment@@aniketsahare6480

    • @aniketsahare6480
      @aniketsahare6480 8 місяців тому

      @@EngineeringDigest Thanks a lot 🤝

    • @manasranjan4
      @manasranjan4 11 днів тому

      Can we make use of bucket selector after aggregation