# Accessing single tag in watcher

**URL:** <https://discuss.elastic.co/t/accessing-single-tag-in-watcher/128776>\
**Category:** Elasticsearch\
**Created:** [April 19, 2018, 11:01pm UTC](https://discuss.elastic.co/t/accessing-single-tag-in-watcher/128776 "2018-04-19T23:01:35Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![pepperhat](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pepperhat/32/26586_2.png) [@pepperhat](https://discuss.elastic.co/u/pepperhat)\
**Post date:** [April 19, 2018, 11:01pm UTC](https://discuss.elastic.co/t/accessing-single-tag-in-watcher/128776/1 "2018-04-19T23:01:35Z")

</div>

Hello All!

I'm setting up a watcher that'll send an email when a query matches, and all of that is working as expected. What I'm attempting to do is access a single value from an array being returned, the first tag.

The following code:

```
{{ctx.payload.hits.hits.0._source.tags}}

```

Returns:  
{ 0=Tag1, 1=Tag2 }

I've tried

```
{{ctx.payload.hits.hits.0._source.tags.0}} 
{{ctx.payload.hits.hits.0._source.tags.0.key}}
{{ctx.payload.hits.hits.0._source.tags.0.value}}

```

None of those appear to be the correct syntax.

I appreciate any assistance from anyone more experienced with the language.

Thanks!

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [April 23, 2018, 1:35pm UTC](https://discuss.elastic.co/t/accessing-single-tag-in-watcher/128776/2 "2018-04-23T13:35:09Z")

</div>

the first variant looks good, see this example (and its output, when you run it yourself):

```auto
POST _xpack/watcher/watch/_execute
{
  "watch": {
    "trigger": {
      "schedule": {
        "interval": "10m"
      }
    },
    "input": {
      "simple": {
        "foo": ["one", "two", "three"]
      }
    },
    "actions": {
      "my-logging": {
        "logging": {
          "text": "{{ctx.payload.foo.0}}"
        }
      }
    }
  }
}

```

---

<div class="post-metadata">

**Author:** ![pepperhat](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pepperhat/32/26586_2.png) [@pepperhat](https://discuss.elastic.co/u/pepperhat)\
**Post date:** [April 23, 2018, 4:13pm UTC](https://discuss.elastic.co/t/accessing-single-tag-in-watcher/128776/3 "2018-04-23T16:13:09Z")

</div>

This is what I get for making multiple changes to my watcher at once, something else was causing the break. Thanks for the confirmation, much appreciated.

---

<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:** [May 21, 2018, 4:13pm UTC](https://discuss.elastic.co/t/accessing-single-tag-in-watcher/128776/4 "2018-05-21T16:13:13Z")

</div>

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