.startsWith Implementation

Need to know proper implementation of startsWith for the url for the script to run in all the 4 cases of document. Error comes for startsWith when runnned.

SCRIPT:-


POST _ingest/pipeline/_simulate
{
  "pipeline": {
    "description": "_description",
    "processors": [
      { 
        "set": {
          "field": "oldURL",
          "value": "{{Image URL}}"
        }, 
        "pipeline": {
          "if": "ctx.Status == 'Fail' && ctx.oldURL.startsWith('http://')", 
          "name": "pass_pipeline"
        }
      },
      {"pipeline":{
         "if": "ctx.Status == 'Fail' ",
          "name": "pass_pipeline"
      }
},
      {
        "pipeline": {
          "if": "ctx.Status == 'Pass' ",
          "name": "fail_pipeline"
        }
      ,
        
        "remove": {
          "field": "ImageURL",
          "ignore_failure": true
        }
      }
    ]
  },
"docs": [
    {
      "_source": {
        "Image URL": "http://1.123.1232.099/screenshots/IndirectLTMediumQuoteAPJIndirectSingapore_20211007130321404.png",
        "Status":"Fail" , "Category":"Failed Test"
        
      }
    },
    {
      "_source": {
        "Image URL": "http://1.1919.1291.9200/screenshots/Empowerment_LowQuoteAMSDirectNVirginia_20211008002205518.png",
        "Status":"Fail" , "Category":"Failed Test"
      }
    },
    {
      "_source": {
        "Image URL":"",
        "Status": "Pass", "Category":"Passed Test"
        }
    },
    {
      "_source": {
        "Image URL": "",
        "Status":"Fail" , "Category":"Failed Test"
      }
    }
  ]
}

Hi, can you post the script of your runtime/scripted field?

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