# Watcher - check if string contains word

**URL:** <https://discuss.elastic.co/t/watcher-check-if-string-contains-word/163620>\
**Category:** Elasticsearch\
**Created:** [January 9, 2019, 9:00pm UTC](https://discuss.elastic.co/t/watcher-check-if-string-contains-word/163620 "2019-01-09T21:00:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![adminek83](https://avatars.discourse-cdn.com/v4/letter/a/e9c0ed/32.png) [@adminek83](https://discuss.elastic.co/u/adminek83)\
**Post date:** [January 9, 2019, 9:00pm UTC](https://discuss.elastic.co/t/watcher-check-if-string-contains-word/163620/1 "2019-01-09T21:00:09Z")

</div>

Hello everyone.  
It is possible to check if some field contains word inside input string? using instruction contains()  
I have this:

```
{
              "script": {
                "script": {
                  "source": "if(doc['exec.stdout.keyword'].toString().contains('cookie'))return true;",
                  "lang": "painless"
                }
              }

```

but this script always return false, I can't use regex, there is no possibility to enable it.

---

<div class="post-metadata">

**Author:** ![adminek83](https://avatars.discourse-cdn.com/v4/letter/a/e9c0ed/32.png) [@adminek83](https://discuss.elastic.co/u/adminek83)\
**Post date:** [January 9, 2019, 10:04pm UTC](https://discuss.elastic.co/t/watcher-check-if-string-contains-word/163620/2 "2019-01-09T22:04:08Z")

</div>

My false... I have something wrong in other place. Now is working, so leave this script for somebody who need it.

---

<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:** [February 6, 2019, 10:04pm UTC](https://discuss.elastic.co/t/watcher-check-if-string-contains-word/163620/3 "2019-02-06T22:04:21Z")

</div>

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