0
0
Elasticsearchquery~10 mins

Creating an index in Elasticsearch - Visual Walkthrough

Choose your learning style9 modes available
Concept Flow - Creating an index
Start
Define index name
Define index settings and mappings
Send PUT request to Elasticsearch
Elasticsearch creates index
Receive confirmation response
Index ready for data
End
This flow shows how you create an index in Elasticsearch by defining its name, settings, and mappings, then sending a request to create it, and finally receiving confirmation.
Execution Sample
Elasticsearch
PUT /my-index
{
  "settings": {
    "number_of_shards": 1
  },
  "mappings": {
    "properties": {"name": {"type": "text"}}
  }
}
This code creates an index named 'my-index' with one shard and a mapping for a 'name' field of type text.
Execution Table
StepActionRequest ContentResponseResult
1Define index name 'my-index'N/AN/AIndex name set
2Define settings: number_of_shards=1{"number_of_shards":1}N/ASettings prepared
3Define mappings: 'name' as text{"properties":{"name":{"type":"text"}}}N/AMappings prepared
4Send PUT request to /my-indexPUT /my-index with settings and mappings{"acknowledged":true,"shards_acknowledged":true,"index":"my-index"}Index created successfully
5Index ready for dataN/AN/AReady to index documents
💡 Index creation acknowledged by Elasticsearch, ready for use.
Variable Tracker
VariableStartAfter Step 1After Step 2After Step 3After Step 4Final
index_nameundefinedmy-indexmy-indexmy-indexmy-indexmy-index
settingsundefinedundefined{"number_of_shards":1}{"number_of_shards":1}{"number_of_shards":1}{"number_of_shards":1}
mappingsundefinedundefinedundefined{"properties":{"name":{"type":"text"}}}{"properties":{"name":{"type":"text"}}}{"properties":{"name":{"type":"text"}}}
responseundefinedundefinedundefinedundefined{"acknowledged":true,"shards_acknowledged":true,"index":"my-index"}{"acknowledged":true,"shards_acknowledged":true,"index":"my-index"}
Key Moments - 2 Insights
Why do we need to define settings and mappings before creating the index?
Settings and mappings tell Elasticsearch how to store and understand data. As shown in execution_table rows 2 and 3, these prepare the index structure before creation in row 4.
What does the response from Elasticsearch mean after sending the PUT request?
The response in execution_table row 4 with "acknowledged":true means Elasticsearch successfully created the index and it is ready to use.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, what is the index_name variable after Step 2?
A"new-index"
B"my-index"
Cundefined
Dnull
💡 Hint
Check variable_tracker row for 'index_name' after Step 2 column.
At which step does Elasticsearch confirm the index creation?
AStep 4
BStep 2
CStep 3
DStep 5
💡 Hint
Look at execution_table response column for acknowledgment.
If you omit the mappings, what would change in the execution flow?
AIndex creation would fail at Step 4
BSettings would be ignored
CStep 3 would be skipped, and index created with default mappings
DResponse would be negative
💡 Hint
Mappings are optional; see how Step 3 prepares mappings before creation.
Concept Snapshot
Creating an index in Elasticsearch:
- Use PUT /index-name
- Define settings (e.g., shards)
- Define mappings (field types)
- Send request
- Receive acknowledgment
- Index ready for data
Full Transcript
To create an index in Elasticsearch, you start by choosing a name for your index. Then you define settings like the number of shards and mappings that describe the fields and their types. Next, you send a PUT request with this information to Elasticsearch. Elasticsearch processes the request and responds with an acknowledgment if successful. After that, the index is ready to store documents. This process ensures your data is organized and searchable as you want.