Populate | Elasticsearch - elasticsearch - elasticsearch tutorial - elastic search
Elasticsearch Populate
- In this segment, we will include some record, mapping and information to Elastic search.
- This information will be utilized as a part of the cases clarified in this instructional exercise.

learn elasticsearch tutorials - populate data request and response Example
Create Index
POST http://localhost:9200/schools
Clicking "Copy Code" button will copy the code into the clipboard - memory. Please paste(Ctrl+V) it in your destination. The code will get pasted. Happy coding from Wikitechy - elasticsearch - elasticsearch tutorial - elastic - elastic search - elasticsearch docker team
Request Body
- It can contain index specific settings, but for now, it is empty for default settings.
elasticsearch - elasticsearch tutorial - elastic search - elasticsearch sort - elasticsearch list indexes - elasticsearch node
Response
{"acknowledged": true}
Clicking "Copy Code" button will copy the code into the clipboard - memory. Please paste(Ctrl+V) it in your destination. The code will get pasted. Happy coding from Wikitechy - elasticsearch - elasticsearch tutorial - elastic - elastic search - elasticsearch docker team
- (This means index is created)
Create Mapping and Add data
- Elastic search will auto-create the mapping according to the data provided in request body, we will use its bulk functionality to add more than one JSON object in this index.
POST http://localhost:9200/schools/_bulk
Clicking "Copy Code" button will copy the code into the clipboard - memory. Please paste(Ctrl+V) it in your destination. The code will get pasted. Happy coding from Wikitechy - elasticsearch - elasticsearch tutorial - elastic - elastic search - elasticsearch docker team
Request Body
{
"index":{
"_index":"schools", "_type":"school", "_id":"1"
}
}
{
"name":"Central School", "description":"CBSE Affiliation", "street":"Nagan",
"city":"paprola", "state":"HP", "zip":"176115", "location":[31.8955385, 76.8380405],
"fees":2000, "tags":["Senior Secondary", "beautiful campus"], "rating":"3.5"
}
{
Clicking "Copy Code" button will copy the code into the clipboard - memory. Please paste(Ctrl+V) it in your destination. The code will get pasted. Happy coding from Wikitechy - elasticsearch - elasticsearch tutorial - elastic - elastic search - elasticsearch docker team
"index":{
"_index":"schools", "_type":"school", "_id":"2"
}
}
{
"name":"Saint Paul School", "description":"ICSE
Afiliation", "street":"Dawarka", "city":"Delhi", "state":"Delhi", "zip":"110075",
"location":[28.5733056, 77.0122136], "fees":5000,
"tags":["Good Faculty", "Great Sports"], "rating":"4.5"
}
{
"index":{"_index":"schools", "_type":"school", "_id":"3"}
}
{
"name":"Crescent School", "description":"State Board Affiliation", "street":"Tonk Road",
"city":"Jaipur", "state":"RJ", "zip":"176114","location":[26.8535922, 75.7923988],
"fees":2500, "tags":["Well equipped labs"], "rating":"4.5"
}
Clicking "Copy Code" button will copy the code into the clipboard - memory. Please paste(Ctrl+V) it in your destination. The code will get pasted. Happy coding from Wikitechy - elasticsearch - elasticsearch tutorial - elastic - elastic search - elasticsearch docker team
Response
{
"took":328, "errors":false,"items":[
{
"index":{
"_index":"schools", "_type":"school", "_id":"1", "_version":1, "_shards":{
"total":2, "successful":1, "failed":0
}, "status":201
}
},
{
"index":{
"_index":"schools", "_type":"school", "_id":"2", "_version":1, "_shards":{
"total":2, "successful":1, "failed":0
}, "status":201
}
},
{
"index":{
"_index":"schools", "_type":"school", "_id":"3", "_version":1, "_shards":{
"total":2, "successful":1, "failed":0
}, "status":201
}
}
]
}
Clicking "Copy Code" button will copy the code into the clipboard - memory. Please paste(Ctrl+V) it in your destination. The code will get pasted. Happy coding from Wikitechy - elasticsearch - elasticsearch tutorial - elastic - elastic search - elasticsearch docker team
Add another Index
Create Index
POST http://localhost:9200/schools_gov
Clicking "Copy Code" button will copy the code into the clipboard - memory. Please paste(Ctrl+V) it in your destination. The code will get pasted. Happy coding from Wikitechy - elasticsearch - elasticsearch tutorial - elastic - elastic search - elasticsearch docker team
Request Body
- It can contain index specific settings, but for now it’s empty for default settings.
Response
{"acknowledged": true} (This means index is created)
Clicking "Copy Code" button will copy the code into the clipboard - memory. Please paste(Ctrl+V) it in your destination. The code will get pasted. Happy coding from Wikitechy - elasticsearch - elasticsearch tutorial - elastic - elastic search - elasticsearch docker team
Create Mapping and Add Data
POST http://localhost:9200/schools_gov/_bulk
Clicking "Copy Code" button will copy the code into the clipboard - memory. Please paste(Ctrl+V) it in your destination. The code will get pasted. Happy coding from Wikitechy - elasticsearch - elasticsearch tutorial - elastic - elastic search - elasticsearch docker team
Request Body
{
"index":{
"_index":"schools_gov", "_type":"school", "_id":"1"
}
}
{
"name":"Model School", "description":"CBSE Affiliation", "street":"silk city",
"city":"Hyderabad", "state":"AP", "zip":"500030", "location":[17.3903703, 78.4752129],
"fees":200, "tags":["Senior Secondary", "beautiful campus"], "rating":"3"
}
{
"index":{
"_index":"schools_gov", "_type":"school", "_id":"2"
}
}
{
"name":"Government School", "description":"State Board Affiliation",
"street":"Hinjewadi", "city":"Pune", "state":"MH", "zip":"411057",
"location": [18.599752, 73.6821995], "fees":500, "tags":["Great Sports"], "rating":"4"
}
Clicking "Copy Code" button will copy the code into the clipboard - memory. Please paste(Ctrl+V) it in your destination. The code will get pasted. Happy coding from Wikitechy - elasticsearch - elasticsearch tutorial - elastic - elastic search - elasticsearch docker team
Response
{
"took":179, "errors":false, "items":[
{
"index":{
"_index":"schools_gov", "_type":"school", "_id":"1", "_version":1, "_shards":{
"total":2, "successful":1, "failed":0
}, "status":201
}
},
{
"index":{
"_index":"schools_gov", "_type":"school", "_id":"2", "_version":1, "_shards":{
"total":2, "successful":1, "failed":0
}, "status":201
}
}
]
}