Create indices, index documents with or without IDs, retrieve, and delete via the REST API.
Indices and Documents
# Create an index with settings
PUT /products
{
"settings": {
"number_of_shards": 1,
"number_of_replicas": 1
}
}
# Index a document (auto-generates ID)
POST /products/_doc
{ "name": "Widget", "price": 9.99, "stock": 100 }
# Index with specific ID
PUT /products/_doc/1
{ "name": "Widget", "price": 9.99, "stock": 100 }
# Get a document
GET /products/_doc/1
# Delete
DELETE /products/_doc/1
DELETE /products # delete entire index
# List indices
GET /_cat/indices?v