elastic search|April 09, 2018|1 min read

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

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

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!

Related Posts

Python SMTP Email Code - How to Send HTML Email from Python Code with Authentication at SMTP Server

Python SMTP Email Code - How to Send HTML Email from Python Code with Authentication at SMTP Server

Introduction This post has the complete code to send email through smtp server…

Common used Elastic Search queries

Common used Elastic Search queries

Listing down the commonly used Elastic Search queries. You can get search…

Troubleshoot AWS Lambda unknown error!

Troubleshoot AWS Lambda unknown error!

After 2 days, there was my demo. I deployed my nodejs code on lambda function…

How to use NPM Rest API to get audit (npm audit) result

How to use NPM Rest API to get audit (npm audit) result

Introduction Npm has a tool called: npm audit which reports if your packages or…

How to sync Mongodb data to ElasticSearch by using MongoConnector

How to sync Mongodb data to ElasticSearch by using MongoConnector

Introduction This post is about syncing your mongodo database data to…

Drupal 8 - How to add custom class to a drupal table view

Drupal 8 - How to add custom class to a drupal table view

Introduction Suppose you have a view, and you have configured your display as a…

Latest Posts

Jenkins Pipeline with Jenkinsfile - How To Schedule Job on Cron and Not on Code Commit

Jenkins Pipeline with Jenkinsfile - How To Schedule Job on Cron and Not on Code Commit

Introduction In this post we will see following: How to schedule a job on cron…

How to Git Clone Another Repository from Jenkin Pipeline in Jenkinsfile

How to Git Clone Another Repository from Jenkin Pipeline in Jenkinsfile

Introduction There are some cases, where I need another git repository while…

How to Fetch Multiple Credentials and Expose them in Environment using Jenkinsfile pipeline

How to Fetch Multiple Credentials and Expose them in Environment using Jenkinsfile pipeline

Introduction In this post, we will see how to fetch multiple credentials and…

Jenkins Pipeline - How to run Automation on Different Environment (Dev/Stage/Prod), with Credentials

Jenkins Pipeline - How to run Automation on Different Environment (Dev/Stage/Prod), with Credentials

Introduction I have an automation script, that I want to run on different…

Jenkinsfile - How to Create UI Form Text fields, Drop-down and Run for Different Conditions

Jenkinsfile - How to Create UI Form Text fields, Drop-down and Run for Different Conditions

Introduction I had to write a CICD system for one of our project. I had to…

Java Log4j Logger - Programmatically Initialize JSON logger with customized keys in json logs

Java Log4j Logger - Programmatically Initialize JSON logger with customized keys in json logs

Introduction Java log4j has many ways to initialize and append the desired…