# .startsWith Implementation

**URL:** <https://discuss.elastic.co/t/startswith-implementation/286489>\
**Category:** Kibana\
**Created:** [October 12, 2021, 12:16pm UTC](https://discuss.elastic.co/t/startswith-implementation/286489 "2021-10-12T12:16:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![varunbsgaur](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/varunbsgaur/32/125005_2.png) [@varunbsgaur](https://discuss.elastic.co/u/varunbsgaur)\
**Post date:** [October 12, 2021, 12:16pm UTC](https://discuss.elastic.co/t/startswith-implementation/286489/1 "2021-10-12T12:16:44Z")

</div>

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:-

```auto

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"
      }
    }
  ]
}

```

---

<div class="post-metadata">

**Author:** ![majagrubic](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/majagrubic/32/74459_2.png) [@majagrubic](https://discuss.elastic.co/u/majagrubic)\
**Post date:** [October 15, 2021, 9:33am UTC](https://discuss.elastic.co/t/startswith-implementation/286489/2 "2021-10-15T09:33:47Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [November 12, 2021, 9:34am UTC](https://discuss.elastic.co/t/startswith-implementation/286489/3 "2021-11-12T09:34:08Z")

</div>

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