Home > other >  How to set the retry on conflict in Elastic search using client.bulk method
How to set the retry on conflict in Elastic search using client.bulk method

Time:11-24

I am using client.bulk method to insert into elastic search. I need to pass the retry_on_conflict param in client.bulk as per the document.

https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update.html

Below code I was trying, but get the error.

const options = {
            index: config.aws.es.index,
            body: bulkBody,
            retry_on_conflict: 5
           // retryOnCflict: 5 (Tried this also) 
        };
        
        
        client.bulk(options, (err, { body }) => {
            if (err) {
                reject(err);
            } else {
                // console.log('ES bulk result: %j', body);
                resolve(body);
            }
        });

Error :

warnings: [
'Client - Unknown parameter: "retryOnConflict", sending it as query parameter'
],

Any one help me that how to add the retry_on_conflict in client.bulk().

CodePudding user response:

Add retry_on_conflict in body of the bulk request as shown here

  • Related