An index in Elasticsearch is like a folder where documents are stored. It helps organize and quickly find data, similar to how a library index helps find books.
Click to reveal answer
beginner
Which HTTP method is used to create an index in Elasticsearch?
The PUT method is used to create an index in Elasticsearch. You send a PUT request to the server with the index name.
Click to reveal answer
intermediate
What is the purpose of the 'mappings' section when creating an index?
Mappings define the structure of the documents in the index, like what fields exist and their data types. It helps Elasticsearch understand how to store and search the data.
Click to reveal answer
beginner
Show a simple example of creating an index named 'library' in Elasticsearch.
Use this command:
PUT /library
This creates an empty index called 'library' ready to store documents.
Click to reveal answer
intermediate
Why should you define settings like number_of_shards when creating an index?
Settings like number_of_shards control how data is split and stored across servers. This affects speed and reliability, like dividing a big book into chapters for easier reading.
Click to reveal answer
Which HTTP method creates a new index in Elasticsearch?
APOST
BGET
CPUT
DDELETE
✗ Incorrect
PUT is used to create or update an index in Elasticsearch.
What does the 'mappings' section define when creating an index?
AThe server location
BThe document structure and field types
CThe user permissions
DThe network protocol
✗ Incorrect
Mappings define the structure and data types of documents in the index.
What is the default number of shards when creating an index if not specified?
A5
B10
C1
D3
✗ Incorrect
By default, Elasticsearch creates 5 primary shards per index (before version 7.0). Since version 7.0, the default is 1 primary shard.
Which of these is a valid command to create an index named 'books'?
ADELETE /books
BPOST /books
CGET /books
DPUT /books
✗ Incorrect
PUT /books creates a new index named 'books'.
Why might you want to customize index settings when creating it?
ATo control data distribution and performance
BTo set user passwords
CTo change the color of the interface
DTo install plugins
✗ Incorrect
Custom settings help control how data is stored and how fast searches run.
Explain how to create a basic index in Elasticsearch and why it is important.
Think about how you organize files in folders.
You got /4 concepts.
Describe the role of mappings and settings when creating an Elasticsearch index.
Consider how a blueprint and building materials affect a house.
You got /3 concepts.
Practice
(1/5)
1. What is the main purpose of creating an index in Elasticsearch?
easy
A. To encrypt data for security
B. To delete data permanently
C. To backup data automatically
D. To organize data for fast searching
Solution
Step 1: Understand the role of an index
An index in Elasticsearch is like a folder that organizes documents to make searching fast and efficient.
Step 2: Compare options with index purpose
Deleting, backing up, or encrypting data are not the main functions of an index.
Final Answer:
To organize data for fast searching -> Option D
Quick Check:
Index = Organize data for search [OK]
Hint: Index means organizing data for quick search [OK]
Common Mistakes:
Confusing index with backup or encryption
Thinking index deletes data
Assuming index automatically secures data
2. Which is the correct syntax to create an index named products in Elasticsearch?
easy
A. PUT /products
B. POST /products
C. GET /products
D. DELETE /products
Solution
Step 1: Recall HTTP methods for index creation
Elasticsearch uses the PUT method to create an index with a specific name.
Step 2: Match method with index name
PUT /products correctly creates the index named 'products'. POST is used for adding documents, GET for retrieving, DELETE for removing.