Index API | Elasticsearch Index APIs - elasticsearch - elasticsearch tutorial - elastic search
Elasticsearch Index APIs
- The Index APIs are in charge of dealing with every one of the parts of list like settings, nom de plumes, mappings, file formats.

Create Index
- This API helps you to create index. Index can be created automatically when a user is passing JSON objects to any index or it can be created before that.
- To create an index, you just need to send a post request with settings, mappings and aliases or just a simple request without body.

learn elasticsearch tutorials - search data - indexes Example
For examplePOST http://localhost:9200/colleges
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
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
- Or, with some settings
POST http://localhost:9200/colleges
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
{
"settings" : {
"index" : {
"number_of_shards" : 5, "number_of_replicas" : 3
}
}
}
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
{"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
- Or with mapping
POST http://localhost:9200/colleges
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
{
"settings" : {
"number_of_shards" : 3
},
"mappings" : {
"type1" : {
"_source" : { "enabled" : false }, "properties" : {
"college_name" : { "type" : "string" }, "college type" : {"type":"string"}
}
}
}
}
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
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
- Or, with alias
POST http://localhost:9200/colleges
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
{
"aliases" : {
"alias_1" : {}, "alias_2" : {
"filter" : {
"term" : {"user" : "manu" }
},
"routing" : "manu"
}
}
}
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
{"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
elasticsearch - elasticsearch tutorial - elastic search - elasticsearch sort - elasticsearch list indexes - elasticsearch node
Delete Index
- This API helps you to delete any index. You just need to pass a delete request with the URL of that particular Index. For example,
DELETE http://localhost:9200/colleges
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
- You can delete all indices by just using _all,*.

Get Index
- This API can be called by just sending get request to one or more than one indices. This returns the information about index.
GET 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
Response
{
"schools":{
"aliases":{}, "mappings":{
"school":{
"properties":{
"city":{"type":"string"}, "description":{"type":"string"},
"fees":{"type":"long"}, "location":{"type":"double"},
"name":{"type":"string"}, "rating":{"type":"string"},
"state":{"type":"string"}, "street":{"type":"string"},
"tags":{"type":"string"}, "zip":{"type":"string"}
}
}
},
"settings":{
"index":{
"creation_date":"1454409831535", "number_of_shards":"5",
"number_of_replicas":"1", "uuid":"iKdjTtXQSMCW4xZMhpsOVA",
"version":{"created":"2010199"}
}
},
"warmers":{}
}
}
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
- You can get the information of all the indices by using _all or *.
Index Exist
- Existence of an index can be determined by just sending a get request to that index. If the HTTP response is 200, it exists; if it is 404, it does not exist.
- It’s very easy to close or open one or more index by just adding _close or _open in post to request to that index. For example,
POST http://localhost:9200/schools/_close
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
- Or
POST http://localhost:9200/schools/_open
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
elasticsearch - elasticsearch tutorial - elastic search - elasticsearch sort - elasticsearch list indexes - elasticsearch node
Index Aliases
- This API helps to give an alias to any index by using _aliases keyword. Single alias can be mapped to more than one and alias cannot have the same name as index. For example,
POST http://localhost:9200/_aliases
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
{
"actions" : [
{ "add" : { "index" : "schools", "alias" : "schools_pri" } }
]
}
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
{"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
- Then,
GET http://localhost:9200/schools_pri
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
{"schools":{"aliases":{"schools_pri":{}},"}}
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 Settings
- You can get the index settings by just appending _settings keyword at the end of URL. For example,
GET http://localhost:9200/schools/_settings
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
{
"schools":{
"settings":{
"index":{
"creation_date":"1454409831535", "number_of_shards":"5",
"number_of_replicas":"1", "uuid":"iKdjTtXQSMCW4xZMhpsOVA",
"version":{"created":"2010199"}
}
}
}
}
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
elasticsearch - elasticsearch tutorial - elastic search - elasticsearch sort - elasticsearch list indexes - elasticsearch node
Analyze
- This API helps to analyze the text and send the tokens with offset value and data type. For example,
POST http://localhost:9200/_analyze
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
{
"analyzer" : "standard",
"text" : "you are reading this at tutorials point"
}
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
elasticsearch - elasticsearch tutorial - elastic search - elasticsearch sort - elasticsearch list indexes - elasticsearch node
Response
{
"tokens":[
{"token":"you", "start_offset":0, "end_offset":3, "type":"<ALPHANUM>", "position":0},
{"token":"are", "start_offset":4, "end_offset":7, "type":"<ALPHANUM>", "position":1},
{"token":"reading", "start_offset":8, "end_offset":15, "type":"<ALPHANUM>", "position":2},
{"token":"this", "start_offset":16, "end_offset":20, "type":"<ALPHANUM>", "position":3},
{"token":"at", "start_offset":21, "end_offset":23, "type":"<ALPHANUM>", "position":4},
{"token":"tutorials", "start_offset":24, "end_offset":33, "type":"<ALPHANUM>", "position":5},
{"token":"point", "start_offset":34, "end_offset":39, "type":"<ALPHANUM>", "position":6}
]
}
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
- You can also analyze a text with any index, and then the text will be analyzed according to the analyzer associated with that index.
Index Templates
- You can also create index templates with mappings, which can be applied to new indices. For example,
POST http://localhost:9200/_template/template_a
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
{
"template" : "tu*",
"settings" : {
"number_of_shards" : 3
},
"mappings" : {
"chapter" : {
"_source" : { "enabled" : false }
}
}
}
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
- Any index that starts with “tu” will have the same settings as template_a.
Index Stats
- This API helps you to extract statistics about a particular index. You just need to send a get request with the index URL and _stats keyword at the end.

learn elasticsearch tutorials - elasticsearch clusters indexers Example
GET http://localhost:9200/schools/_stats
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
{"_shards":{"total":10, "successful":5, "failed":0}, "_all":{"primaries":{"docs":{
"count":3, "deleted":0}}}, "store":{"size_in_bytes":16653, "throttle_time_in_millis":0},
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 API helps to clean the data from index memory and migrate it to index storage and also cleans internal transaction log. For example,
GET http://localhost:9200/schools/_flush
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
{"_shards":{"total":10, "successful":5, "failed":0}}
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
Refresh
- Refresh is scheduled by default in Elastic search, but you can refresh one or more indices explicitly by using _refresh. For example,
GET http://localhost:9200/schools/_refresh
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
elasticsearch - elasticsearch tutorial - elastic search - elasticsearch sort - elasticsearch list indexes - elasticsearch node
Response
{"_shards":{"total":10, "successful":5, "failed":0}}