Org.elsticsearch -- trying to run scripted upserts, written in painless language, from Spark -- {type=null_pointer_exception, reason=null}

Hi There,

I am trying to run the following code

 // .option("es.nodes.discovery", "false")
 // .option("es.nodes.client.only", "false")
  .option("", "fileName")
  .option("es.write.operation", "upsert")
  .option("es.nodes", esURL)

and getting following error illegal_argument_exception: failed to execute script; script_exception: runtime error; 
{type=null_pointer_exception, reason=null}

My Painless Code is

      "_id" : "mp-upsert-with-dup-check-and-revisions",
      "found" : true,
      "script" : {
        "lang" : "painless",
        "source" : """
                    // Get Old and New Documents
                    def old_source = new HashMap(ctx._source);
                    def new_source = new HashMap(params.newsource);

                    // Duplicate Check
                    def pure_old_source = new HashMap(ctx._source);
                    def pure_new_source = new HashMap(params.newsource);
                    // Noop Check and Revision Tracking
                    if(pure_old_source == pure_new_source){
                      ctx.op = 'none';
                      if(old_source.ingestion_meta != null){
                        if(old_source._revisions == null){
                          new_source._revisions = [];
                          new_source._revisions = new ArrayList(old_source._revisions);

                    // Add Ingestion_Meta if missing
                    if(new_source.ingestion_meta == null){
                        new_source.ingestion_meta = new HashMap();
                    // Add created_at timestamp
                    if(old_source.ingestion_meta == null){
                      new_source.ingestion_meta.created_at = ctx._now;
                      new_source.ingestion_meta.created_at = old_source.ingestion_meta.created_at;
                    // Add modified_at timestamp
                    new_source.ingestion_meta.modified_at = ctx._now;
                    ctx._source = new_source;


I think this feature has still not been added to es.hadoop package.

Written on this URL

moving on, it is also the last comment on this URL

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.