-
Notifications
You must be signed in to change notification settings - Fork 70
Ch 5. Document Operations
Madhusudhan Konda edited this page Jul 7, 2021
·
7 revisions
Indexing a movie document with an identifier:
//Request
PUT movies/_doc/1
{
"title":"The Godfather",
"synopsis":"The aging patriarch of an organized crime dynasty transfers control of his clandestine empire to his reluctant son"
}
// REsponse:
{
"_index" : "movies",
"_type" : "_doc",
"_id" : "1",
"_version" : 1,
"_seq_no" : 0,
"_primary_term" : 1,
"found" : true,
"_source" : {
"title" : "The Godfather",
"synopsis" : "The aging patriarch of an organized crime dynasty transfers control of his clandestine empire to his reluctant son"
}
}
Indexing a movie review document - the document isn't expected to have an ID provided by the user (note the POST method invocation):
// Request
POST movies_reviews/_doc
{
"movie":"The Godfather",
"user":"Peter Piper",
"rating":4.5,
"remarks":"The movie started with a .."
}
// Response:
{
"_index" : "movies_reviews",
"_type" : "_doc",
"_id" : "6HPnfXoBW8A1B2am0B5U",
"_version" : 1,
"result" : "created",
"_shards" : {
"total" : 4,
"successful" : 1,
"failed" : 0
},
"_seq_no" : 0,
"_primary_term" : 1
}
The ID was not provided by the user. System generated one (6HPnfXoBW8A1B2am0B5U
) and assigned to the document