0
0
Elasticsearchquery~30 mins

Elasticsearch vs relational databases - Hands-On Comparison

Choose your learning style9 modes available
Comparing Elasticsearch and Relational Databases
📖 Scenario: You work in a company that stores customer data. You want to see how Elasticsearch and relational databases handle searching and storing data differently.
🎯 Goal: Build a simple example to store and search customer data using Elasticsearch queries and compare it with relational database style queries.
📋 What You'll Learn
Create a sample dataset of customers with name and age
Set a minimum age filter value
Write an Elasticsearch query to find customers older than the minimum age
Print the query JSON to see the output
💡 Why This Matters
🌍 Real World
Elasticsearch is used for fast, flexible searching in big data, while relational databases are used for structured data storage and complex transactions.
💼 Career
Understanding both helps in roles like data engineering, backend development, and search engine optimization.
Progress0 / 4 steps
1
Create the customer data
Create a variable called customers that holds a list of dictionaries with these exact entries: {"name": "Alice", "age": 30}, {"name": "Bob", "age": 25}, and {"name": "Charlie", "age": 35}.
Elasticsearch
Need a hint?

Use a list with dictionaries for each customer.

2
Set the minimum age filter
Create a variable called min_age and set it to 30.
Elasticsearch
Need a hint?

Just assign the number 30 to min_age.

3
Write the Elasticsearch query
Create a variable called es_query that holds a dictionary representing an Elasticsearch query to find customers with age greater than or equal to min_age. Use the range query on the age field with gte set to min_age.
Elasticsearch
Need a hint?

Use nested dictionaries to build the query structure.

4
Print the Elasticsearch query
Write a print statement to display the es_query variable.
Elasticsearch
Need a hint?

Use print(es_query) to show the query.