---
setup:
- skip:
    features:
    - "headers"
    - "allowed_warnings_regex"
- do:
    indices.create:
      index: "test_1"
      body:
        settings:
          index.mapping.nested_objects.limit: 2
        mappings:
          properties:
            nested1:
              type: "nested"
    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"
---
Indexing a doc with No. nested objects less or equal to index.mapping.nested_objects.limit should succeed:
- do:
    create:
      index: "test_1"
      id: "1"
      body:
        nested1:
        - foo: "bar"
        - foo: "bar2"
    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:
    _version: 1
---
Indexing a doc with No. nested objects more than index.mapping.nested_objects.limit should fail:
- do:
    catch: "/The number of nested documents has exceeded the allowed limit of \\[2\\\
      ]. This limit can be set by changing the \\[index.mapping.nested_objects.limit\\\
      ] index level setting\\./"
    create:
      index: "test_1"
      id: "1"
      body:
        nested1:
        - foo: "bar"
        - foo: "bar2"
        - foo: "bar3"
    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"
