kibana/x-pack/plugins/stack_alerts/common
Ersin Erdal 58204cf2a0
Add date_nanos support to Time field (#151374)
Fixes: #145855 

`Time field` in rule update/create forms shows only the fields with
`date` data type. This PR adds `date_nanos` type as well.

## To verify:

- Create an index that has fields with `date` and `date_nanos` types.
```
PUT test-index-date
{
  "mappings": {
    "properties": {
      "date": {
        "type": "date"
      },
      "timestamp": {
        "type": "date_nanos"
      }
    }
  }
}
```
- Add data with `date` and `date_nanos` data types
Note: You can use
https://www.site24x7.com/tools/time-stamp-converter.html address to
generate date_nanos timestamps with a date you desired.
```
PUT test-index-date/_bulk?refresh
{ "index" : { "_id" : "1" } }
{ "date": "2023-02-15T18:00:00.000Z", "timestamp": 1676480400000} 
{ "index" : { "_id" : "2" } }
{ "date": "2023-02-15T18:00:00.000Z", "timestamp": 1676480400000 } 
```
- Open a Rule create form and select `Elasticsearch query`
- Select `Query DSL`
- Click on `select an index`
- Type the above index name (test-index-date) in `Indices to query`
input
- Select `timestamp` from time field
- Click on `Test Query` button and expect to see `Query matched 2
documents in the last 5m.`
2023-02-21 16:25:09 +01:00
..
build_sorted_events_query.test.ts Add date_nanos support to Time field (#151374) 2023-02-21 16:25:09 +01:00
build_sorted_events_query.ts Add date_nanos support to Time field (#151374) 2023-02-21 16:25:09 +01:00
comparator.test.ts [Response Ops][Alerting] Adding group by options to ES query rule type (#144689) 2022-12-15 11:03:58 -05:00
comparator.ts [Response Ops][Alerting] Adding group by options to ES query rule type (#144689) 2022-12-15 11:03:58 -05:00
comparator_types.ts [Discover] Extend Elasticsearch query rule with search source based data fetching (#124534) 2022-04-01 14:57:57 +05:00
constants.ts [Unified Search] Fix regress autocomplete (#140880) 2022-09-21 16:29:46 +05:00
index.ts [Response Ops][Alerting] Adding group by options to ES query rule type (#144689) 2022-12-15 11:03:58 -05:00