# How to Compare two different fields value of two different index?

**URL:** https://discuss.elastic.co/t/how-to-compare-two-different-fields-value-of-two-different-index/132533
**Category:** Elasticsearch
**Tags:** elastic-stack-alerting
**Created:** [May 18, 2018, 7:28pm UTC](https://discuss.elastic.co/t/how-to-compare-two-different-fields-value-of-two-different-index/132533 "2018-05-18T19:28:42Z")
**Posts on this page:** 1
**Showing post:** 11

<div class="post-metadata">

### Author: ![addanuj](https://avatars.discourse-cdn.com/v4/letter/a/d2c977/32.png) [@addanuj](https://discuss.elastic.co/u/addanuj)
#### Post date: [May 24, 2018, 6:48pm UTC](https://discuss.elastic.co/t/how-to-compare-two-different-fields-value-of-two-different-index/132533/11 "2018-05-24T18:48:29Z")

</div>

i have removed the timestamp as my index do not have it. my bad...  
i tried this ---

```
POST _xpack/watcher/watch/_execute
{
  "watch": 
  {
        "trigger": {
    "schedule": {
      "interval": "30m"
    }
  },
  "input": {
    "search": {
      "request": {
        "search_type": "query_then_fetch",
        "indices": [
          "checkpoint*"
        ],
        "types": [],
        "body": {
          "size": 0,
          "query": {
            "match_all": {}
          }
        }
      }
    }
  },
  "condition": {
    "compare": {
      "ctx.payload.hits.total": {
        "gte": 1
      }
    }
  },
  "actions": {
    "my-logging-action": {
      "logging": {
        "level": "info",
        "text": "ip is {{ctx.payload.hits.hits.0._source.srcip}} "
      }
    }
  }

  }
}
```

---

_[View the full topic](https://discuss.elastic.co/t/how-to-compare-two-different-fields-value-of-two-different-index/132533)._
