---
setup:
- skip:
    features:
    - "headers"
    - "allowed_warnings_regex"
---
multiple subobjects:
- requires:
    cluster_features:
    - "gte_v8.12.0"
    reason: "counted_keyword was added in 8.12"
- do:
    indices.create:
      index: "test-events"
      body:
        mappings:
          properties:
            parent:
              type: "object"
              properties:
                child:
                  type: "counted_keyword"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - ".*rollup functionality will be removed in Elasticsearch.*"
    - "Index \\[\\.profiling-.*\\] name begins with a dot.* and will not be allowed\
      \ in a future Elasticsearch version."
    - "Parameter \\[default_metric\\] is deprecated and will be removed in a future\
      \ version"
- do:
    index:
      index: "test-events"
      id: "1"
      refresh: true
      body: "{\"parent\": [{\"child\": \"foo\"}, {\"child\": \"bar\"}]}"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - ".*rollup functionality will be removed in Elasticsearch.*"
    - "Index \\[\\.profiling-.*\\] name begins with a dot.* and will not be allowed\
      \ in a future Elasticsearch version."
    - "Parameter \\[default_metric\\] is deprecated and will be removed in a future\
      \ version"
- do:
    search:
      index: "test-events"
      body:
        query:
          ids:
            values:
            - 1
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - ".*rollup functionality will be removed in Elasticsearch.*"
    - "Index \\[\\.profiling-.*\\] name begins with a dot.* and will not be allowed\
      \ in a future Elasticsearch version."
    - "Parameter \\[default_metric\\] is deprecated and will be removed in a future\
      \ version"
- match:
    hits.hits.0._source:
      parent:
      - child: "foo"
      - child: "bar"
