---
setup:
- skip:
    features:
    - "headers"
    - "allowed_warnings_regex"
---
date_nanos requires dates after 1970 and before 2262:
- requires:
    cluster_features:
    - "gte_v8.8.0"
    reason: "error message changed in 8.8.0"
- do:
    indices.create:
      index: "date_ns"
      body:
        settings:
          number_of_shards: 3
          number_of_replicas: 0
        mappings:
          properties:
            date:
              type: "date_nanos"
            field:
              type: "long"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- do:
    bulk:
      refresh: true
      body:
      - "{ \"index\" : { \"_index\" : \"date_ns\", \"_id\" : \"date_ns_1\" } }"
      - "{\"date\" : \"1969-10-28T12:12:12.123456789Z\" }"
      - "{ \"index\" : { \"_index\" : \"date_ns\", \"_id\" : \"date_ns_2\" } }"
      - "{\"date\" : \"2263-10-29T12:12:12.123456789Z\" }"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- match:
    errors: true
- match:
    items.0.index.status: 400
- match:
    items.0.index.error.type: "document_parsing_exception"
- match:
    items.0.index.error.caused_by.reason: "date[1969-10-28T12:12:12.123456789Z] is\
      \ before the epoch in 1970 and cannot be stored in nanosecond resolution"
- match:
    items.1.index.status: 400
- match:
    items.1.index.error.type: "document_parsing_exception"
- match:
    items.1.index.error.caused_by.reason: "date[2263-10-29T12:12:12.123456789Z] is\
      \ after 2262-04-11T23:47:16.854775807 and cannot be stored in nanosecond resolution"
