Issue trying to make ponctuality test using watchers

Hi all,
I have an issue and I hope you can help me.
Here is my code:

PUT _xpack/watcher/watch/test_ponctuality
    {
      "trigger" : { 
        "schedule" : {
          "interval" : "10s"
        }
      },
      "input" : { 
        "chain" : {
          "inputs" : [
            {
              "first" : {
                  "search" : {
                      "request" : {
                          "indices" : [ "fileparams" ],
                          "body" : {
                              "query" : {
                                  "match_all" : {}
                              }
                          }
                      }
                  }
              }
            },
            {
              "second" : {
                "search" : {
                      "request" : {
                          "indices" : [ "ponctuality" ],
                          "body" : {
                              "query" : {
                                  "match_all" : { }
                              }
                          }
                      }
                  }
              }
            }
          ]}},
          "condition" : {
          "script" : {
            "lang" : "painless",
            "source": """
                for(int i=0;i<ctx.payload.first.hits.total;i++){
                   for(int j=0;j<ctx.payload.second.hits.total;j++){
                          if(ctx.payload.first.hits.hits.i._source.file_id==ctx.payload.second.hits.hits.j._source.interfaceSequence){
                              if (ctx.payload.first.hits.hits.i._source.scheduledArrivalTime< executionDate){
                                  ctx.payload.second.hits.hits.j._source.ponctuality = "ok";
                            
                              }else{
                                ctx.payload.second.hits.hits.j._source.ponctuality = "late"
                                
                              }
                          }
                    }
                  }
                 
                    return true; 
                 
                        """
            }
          },
      "actions" : { 
        "index_payload" : { 
          "index" : {
            "index" : "test",
            "doc_type":"doc"
        }
      }
      }
    }

Code explanation
I have an Index fileparams in witch documents say: I want this "file_id" to arrive before "scheduledArrivalTime" I am trying to use watcher to survey the ponctuality data and if they are late add an attribute "ponctuality" at "late" and if it arrived on time put it at "ok".
This code above des not work and the only error elastic search show me is :[2019-02-18T11:46:55,054][WARN ][o.e.x.w.e.ExecutionService] [CUiEBk2] failed to execute watch [test_ponctuality]

I am obviously new at elasticsearch so maybe I am not using the right tools to do what I need. I am open to every suggestions^^.
Please advise.

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