Use the `_doc` endpoint to write one JSON document at a known location in an Elasticsearch index. With `PUT`, the URL includes the index, `_doc`, and a client-chosen document ID; Elasticsearch stores the request body under that ID. section 5.1.1
Index a movie with an ID
`PUT movies/_doc/1` writes a movie document to the `movies` index with ID `1`. The JSON body contains the document data, such as its title and synopsis. section 5.1.1
Listing 5.1 Indexing a new document into the movies index
PUT movies/_doc/1 #1
{ #2
"title":"The Godfather",
"synopsis":"The aging patriarch of an organized crime dynasty transfers
control of his clandestine empire to his reluctant son"
}
The request path separates the index (`movies`), document endpoint (`_doc`), and document identifier (`1`) from the JSON payload. section 5.1.1
When no ID is supplied, send `POST <index>/_doc`; Elasticsearch assigns a random UUID. Use `PUT <index>/_doc/<id>` when the client supplies the ID. section 5.1.1
Sending another `PUT` request to the same `_doc` ID replaces the existing document with the new request body. Choose `_create` instead when existing content must not be replaced. section 5.4.4 section 5.1.1
Reusing ID `1` with a new body replaces the earlier movie data with the `Avatar` document. section 5.4.4
