While dealing with ELastic Search documents, you faced this issue while updating document:

ElasticSearch: Validation Failed: 1: script or doc is missing;

Reason

When you insert documents to ElasticSearch, you write something like:

{
    index: 'your_index_name',
    type: 'your_type',
    body: {
       title: 'this is my sample title',
       createdAt: 'some_date'
    },
    refresh: true
}

But, when you want to update the documents. There is a slight change in json. See example:

{
    index: 'your_index_name',
    type: 'your_type',
    id: 'document_id',
    body: {
       doc: {
          title: 'this is my sample title',
          createdAt: 'some_date'
       }
    },
    refresh: true
}

Notice the extra “doc” in there. Generally, users tend to put json without “doc”, and it caused this error.

Enjoy!