# Watcher chain input, matching result set not found in action results

**URL:** <https://discuss.elastic.co/t/watcher-chain-input-matching-result-set-not-found-in-action-results/200534>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-alerting\
**Created:** [September 21, 2019, 3:49pm UTC](https://discuss.elastic.co/t/watcher-chain-input-matching-result-set-not-found-in-action-results/200534 "2019-09-21T15:49:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![elk\_novice](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/elk_novice/32/48249_2.png) [@elk\_novice](https://discuss.elastic.co/u/elk_novice)\
**Post date:** [September 21, 2019, 3:49pm UTC](https://discuss.elastic.co/t/watcher-chain-input-matching-result-set-not-found-in-action-results/200534/1 "2019-09-21T15:49:21Z")

</div>

Hi, I am able to successfully execute the watcher which compares the field value in two different indices. However, I am not able to see the matching result. what I get is only first and second input values. I want to see only the matching documents, The output is as follows Please help.

"input": {  
"chain": {  
"inputs": [  
{  
"first": {  
"search": {  
"request": {  
"search\_type": "query\_then\_fetch",  
"indices": [  
"test"  
],  
"rest\_total\_hits\_as\_int": true,  
"body": {  
"query": {  
"match\_all": {}  
}  
{  
"second": {  
"search": {  
"request": {  
"search\_type": "query\_then\_fetch",  
"indices": [  
"test123"  
],  
"  
"condition": {  
"script": {  
"source": "def second\_results = ctx.payload.second.hits.hits.stream().map(hit-\>hit.\_source.id).collect(Collectors.toList()); return ctx.payload.first.hits.hits.stream().map(hit -\> hit.\_source.id).filter(p-\>second\_results.contains(p)).collect(Collectors.toList()).size() \> 0;",  
"lang": "painless"  
}  
},

"result": {  
"input": {  
"type": "chain",  
"status": "success",  
"payload": {  
"first": {  
"hits": {  
"hits": [  
{  
"\_index": "test",  
"\_type": "\_doc",  
"\_source": {  
"name": "raju",  
"id": 1  
},  
"\_id": "0XA0SW0Bvfhb-n5H1IFL",  
"\_score": 1  
},  
{  
"\_index": "test",  
"\_type": "\_doc",  
"\_source": {  
"name": "rama",  
"id": 2  
},  
"\_id": "0nA1SW0Bvfhb-n5HF5op",  
"\_score": 1  
}  
],  
"total": 2,  
"max\_score": 1  
},  
"took": 1,  
"timed\_out": false  
},  
"second": {  
"hits": {  
"hits": [  
{  
"\_index": "test123",  
"\_type": "\_doc",  
"\_source": {  
"name": "teju",  
"id": 1  
},  
"\_id": "AnFDSW0Bvfhb-n5HmM1w",  
"\_score": 1  
},  
{  
"\_index": "test123",  
"\_type": "\_doc",  
"\_source": {  
"name": "teju",  
"id": 1  
},  
"\_id": "k00QSm0Bvfhb-n5H4XUu",  
"\_score": 1  
},  
{  
"\_index": "test123",  
"\_type": "\_doc",  
"\_source": {  
"name": "mast",  
"id": 4  
},  
"\_id": "lLtRUm0Bvfhb-n5HEYiF",  
"\_score": 1  
}  
],  
"total": 3,  
"max\_score": 1  
},  
"chain": {  
"first": {  
"type": "search",  
"status": "success",  
"payload": {  
"\_shards": {  
"total": 1,  
"failed": 0,  
"successful": 1,  
"skipped": 0  
},  
"hits": {  
"hits": [  
{  
"\_index": "test",  
"\_type": "\_doc",  
"\_source": {  
"name": "raju",  
"id": 1  
},  
"\_id": "0XA0SW0Bvfhb-n5H1IFL",  
"\_score": 1  
},  
{  
"\_index": "test",  
"\_type": "\_doc",  
"\_source": {  
"name": "rama",  
"id": 2  
},  
"\_id": "0nA1SW0Bvfhb-n5HF5op",  
"\_score": 1  
}  
],  
"total": 2,  
"max\_score": 1  
},  
"took": 1,  
"timed\_out": false  
},  
"search": {  
"request": {  
"search\_type": "query\_then\_fetch",  
"indices": [  
"test"  
],  
"rest\_total\_hits\_as\_int": true,  
"body": {  
"query": {  
"match\_all": {}  
}  
}  
}  
}  
},  
"second": {  
"type": "search",  
"status": "success",  
"payload": {  
"\_shards": {  
"total": 1,  
"failed": 0,  
"successful": 1,  
"skipped": 0  
},  
"hits": {  
"hits": [  
{  
"\_index": "test123",  
"\_type": "\_doc",  
"\_source": {  
"name": "teju",  
"id": 1  
},  
"\_id": "AnFDSW0Bvfhb-n5HmM1w",  
"\_score": 1  
},  
{  
"\_index": "test123",  
"\_type": "\_doc",  
"\_source": {  
"name": "teju",  
"id": 1  
},  
"\_id": "k00QSm0Bvfhb-n5H4XUu",  
"\_score": 1  
},  
{  
"\_index": "test123",  
"\_type": "\_doc",  
"\_source": {  
"name": "mast",  
"id": 4  
},  
"\_id": "lLtRUm0Bvfhb-n5HEYiF",  
"\_score": 1  
}  
],  
"total": 3,  
"max\_score": 1  
},  
"took": 1,  
"timed\_out": false  
},

```
"condition": {
  "type": "script",
  "status": "success",
  "met": true
},
"actions": [
  {
    "id": "log",
    "type": "logging",
    "status": "simulated",
    "logging": {
      "logged_text": "{first={_shards={total=1, failed=0, successful=1, skipped=0}, hits={hits=[{_index=test, _type=_doc, _source={name=raju, id=1}, _id=0XA0SW0Bvfhb-n5H1IFL, _score=1.0}, {_index=test, _type=_doc, _source={name=rama, id=2}, _id=0nA1SW0Bvfhb-n5HF5op, _score=1.0}], total=2, max_score=1.0}, took=1, timed_out=false}, second={_shards={total=1, failed=0, successful=1, skipped=0}, hits={hits=[{_index=test123, _type=_doc, _source={name=teju, id=1}, _id=AnFDSW0Bvfhb-n5HmM1w, _score=1.0}, {_index=test123, _type=_doc, _source={name=teju, id=1}, _id=k00QSm0Bvfhb-n5H4XUu, _score=1.0}, {_index=test123, _type=_doc, _source={name=mast, id=4}, _id=lLtRUm0Bvfhb-n5HEYiF, _score=1.0}], total=3, max_score=1.0}, took=1, timed_out=false}}"

```

},  
"messages":

---

<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:** [September 25, 2019, 12:18pm UTC](https://discuss.elastic.co/t/watcher-chain-input-matching-result-set-not-found-in-action-results/200534/2 "2019-09-25T12:18:06Z")

</div>

Hey,

please take the time and properly format your message, as this is hard to read. Thanks!

So, the condition only returns true or false, but does not store the result of its calculation somewhere. You can do this either in a transform, or add a field in `ctx.payload` as part of the condition like `ctx.payload.condition_data = [:]`.

hope this helps!

---

<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:** [October 23, 2019, 12:18pm UTC](https://discuss.elastic.co/t/watcher-chain-input-matching-result-set-not-found-in-action-results/200534/3 "2019-10-23T12:18:16Z")

</div>

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