Discover helps you look at your data quickly. It shows you raw data so you can understand what is inside your Elasticsearch index.
Discover for data exploration in Elasticsearch
Start learning this pattern below
Jump into concepts and practice - no test required
or
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Introduction
Syntax
Elasticsearch
GET /your-index-name/_search
{
"query": {
"match_all": {}
},
"size": 10
}This is a basic Elasticsearch query to get 10 documents from an index.
Discover in Kibana uses similar queries behind the scenes to show data.
Examples
Elasticsearch
GET /logs-2024/_search
{
"query": {
"match": {
"message": "error"
}
},
"size": 5
}Elasticsearch
GET /sales-data/_search
{
"query": {
"range": {
"date": {
"gte": "2024-01-01",
"lte": "2024-01-31"
}
}
},
"size": 10
}Sample Program
This example fetches 3 documents from 'my-index' to explore the data.
Elasticsearch
GET /my-index/_search
{
"query": {
"match_all": {}
},
"size": 3
}Important Notes
Discover shows raw documents so you can see exactly what data is stored.
You can filter and search in Discover to narrow down data quickly.
Discover is a great first step before building visualizations or dashboards.
Summary
Discover lets you explore raw data in Elasticsearch indexes.
You use simple queries to find and filter data.
It helps you understand your data before deeper analysis.
Practice
1. What is the main purpose of the Discover feature in Elasticsearch?
easy
Solution
Step 1: Understand Discover's role
Discover is designed to let users explore raw data quickly and easily.Step 2: Compare with other features
Dashboard creation and cluster management are separate features, not Discover's focus.Final Answer:
To explore and filter raw data in indexes -> Option AQuick Check:
Discover = Data exploration [OK]
Hint: Discover = explore raw data quickly [OK]
Common Mistakes:
- Confusing Discover with Dashboard
- Thinking Discover manages cluster settings
- Assuming Discover creates complex queries
2. Which of the following is the correct syntax to filter data in Discover using a simple query?
easy
Solution
Step 1: Identify Discover query syntax
Discover uses Lucene query syntax likefield:valueand logical operators like AND.Step 2: Eliminate SQL and function syntax
Options A, C, and D use SQL or function style, which is not valid in Discover queries.Final Answer:
status:200 AND extension:jpg -> Option CQuick Check:
Lucene syntax = status:200 AND extension:jpg [OK]
Hint: Use field:value with AND/OR in Discover queries [OK]
Common Mistakes:
- Using SQL syntax instead of Lucene
- Using function calls for filtering
- Mixing query languages
3. Given the following Discover query:
response:404 OR response:500, what data will be shown?medium
Solution
Step 1: Understand OR operator in query
The OR operator returns documents matching either condition, not both simultaneously.Step 2: Apply to response codes
Documents with response 404 or response 500 will be included in results.Final Answer:
Documents with response code 404 or 500 -> Option DQuick Check:
OR means either condition matches [OK]
Hint: OR returns either condition matches [OK]
Common Mistakes:
- Thinking OR means both conditions together
- Confusing OR with AND
- Assuming exclusion of matching documents
4. You wrote this Discover query:
status:200 AND extension=jpg. Why does it cause an error?medium
Solution
Step 1: Check field-value syntax
Discover usesfield:valuesyntax, notfield=value.Step 2: Validate operators and values
AND is valid, 'status' is a common field, and quotes are optional for simple values.Final Answer:
Because '=' is not valid; use ':' for field-value pairs -> Option AQuick Check:
Use ':' not '=' in queries [OK]
Hint: Use colon ':' for field-value, not equals '=' [OK]
Common Mistakes:
- Using '=' instead of ':'
- Misunderstanding AND operator usage
- Adding unnecessary quotes
5. You want to explore documents where the field
user exists and the bytes field is greater than 1000. Which Discover query achieves this?hard
Solution
Step 1: Check existence syntax
Use_exists_:userto find documents where 'user' field exists.Step 2: Use range query for bytes > 1000
Range syntaxbytes:{1000 TO *}means bytes greater than 1000 (exclusive).Step 3: Verify other options
_exists_:user AND bytes:>1000and C have invalid range syntax;user:* AND bytes:>1000uses wildcard incorrectly for existence.Final Answer:
_exists_:user AND bytes:{1000 TO *} -> Option BQuick Check:
Existence + range query =_exists_:user AND bytes:{1000 TO *}[OK]
Hint: Use _exists_ for field and range syntax for > value [OK]
Common Mistakes:
- Using wildcard * for existence check
- Incorrect range syntax for greater than
- Confusing inclusive and exclusive ranges
