---
setup:
- skip:
    features:
    - "headers"
    - "allowed_warnings_regex"
- requires:
    cluster_features:
    - "mapper.source.mode_from_index_setting"
    reason: "Source mode configured through index setting"
---
ignore_above mapping level setting:
- requires:
    cluster_features:
    - "mapper.ignore_above_index_level_setting"
    reason: "introduce ignore_above index level setting"
- do:
    indices.create:
      index: "test"
      body:
        settings:
          index:
            mapping:
              source.mode: "synthetic"
              ignore_above: 10
        mappings:
          properties:
            keyword:
              type: "keyword"
            flattened:
              type: "flattened"
    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:
    index:
      index: "test"
      refresh: true
      id: "1"
      body:
        keyword: "foo bar"
        flattened:
          value: "the quick brown fox"
    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:
    search:
      body:
        fields:
        - "keyword"
        - "flattened"
        query:
          match_all: {}
    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"
- length:
    hits.hits: 1
- match:
    hits.hits.0._source.keyword: "foo bar"
- match:
    hits.hits.0._source.flattened.value: "the quick brown fox"
- match:
    hits.hits.0.fields.keyword.0: "foo bar"
---
ignore_above mapping level setting on arrays:
- requires:
    cluster_features:
    - "mapper.flattened.ignore_above_with_arrays_support"
    reason: "requires support of ignore_above with arrays for flattened fields"
- do:
    indices.create:
      index: "test"
      body:
        settings:
          index:
            mapping:
              source.mode: "synthetic"
              ignore_above: 10
        mappings:
          properties:
            keyword:
              type: "keyword"
            flattened:
              type: "flattened"
    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:
    index:
      index: "test"
      refresh: true
      id: "1"
      body:
        keyword:
        - "foo bar"
        - "the quick brown fox"
        flattened:
          value:
          - "the quick brown fox"
          - "jumps over"
    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:
    search:
      body:
        fields:
        - "keyword"
        - "flattened"
        query:
          match_all: {}
    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"
- length:
    hits.hits: 1
- match:
    hits.hits.0._source.keyword:
    - "foo bar"
    - "the quick brown fox"
- match:
    hits.hits.0._source.flattened.value:
    - "jumps over"
    - "the quick brown fox"
- match:
    hits.hits.0.fields.keyword.0: "foo bar"
- match:
    hits.hits.0.fields.flattened.0.value: "jumps over"
---
ignore_above mapping overrides setting:
- requires:
    cluster_features:
    - "mapper.ignore_above_index_level_setting"
    reason: "introduce ignore_above index level setting"
- do:
    indices.create:
      index: "test"
      body:
        settings:
          index:
            mapping:
              source.mode: "synthetic"
              ignore_above: 10
        mappings:
          properties:
            keyword:
              type: "keyword"
              ignore_above: 100
            flattened:
              type: "flattened"
              ignore_above: 100
    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:
    index:
      index: "test"
      refresh: true
      id: "1"
      body:
        keyword: "foo bar baz foo bar baz"
        flattened:
          value: "the quick brown fox"
    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:
    search:
      body:
        fields:
        - "keyword"
        - "flattened"
        query:
          match_all: {}
    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"
- length:
    hits.hits: 1
- match:
    hits.hits.0._source.keyword: "foo bar baz foo bar baz"
- match:
    hits.hits.0._source.flattened.value: "the quick brown fox"
- match:
    hits.hits.0.fields.keyword.0: "foo bar baz foo bar baz"
- match:
    hits.hits.0.fields.flattened.0.value: "the quick brown fox"
---
ignore_above mapping overrides setting on arrays:
- requires:
    cluster_features:
    - "mapper.ignore_above_index_level_setting"
    reason: "introduce ignore_above index level setting"
- do:
    indices.create:
      index: "test"
      body:
        settings:
          index:
            mapping:
              source.mode: "synthetic"
              ignore_above: 10
        mappings:
          properties:
            keyword:
              type: "keyword"
              ignore_above: 100
            flattened:
              type: "flattened"
              ignore_above: 100
    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:
    index:
      index: "test"
      refresh: true
      id: "1"
      body:
        keyword:
        - "foo bar baz foo bar baz"
        - "the quick brown fox jumps over"
        flattened:
          value:
          - "the quick brown fox"
          - "jumps over the lazy dog"
    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:
    search:
      body:
        fields:
        - "keyword"
        - "flattened"
        query:
          match_all: {}
    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"
- length:
    hits.hits: 1
- match:
    hits.hits.0._source.keyword:
    - "foo bar baz foo bar baz"
    - "the quick brown fox jumps over"
- match:
    hits.hits.0._source.flattened.value:
    - "jumps over the lazy dog"
    - "the quick brown fox"
- match:
    hits.hits.0.fields.keyword:
    - "foo bar baz foo bar baz"
    - "the quick brown fox jumps over"
- match:
    hits.hits.0.fields.flattened.0.value:
    - "jumps over the lazy dog"
    - "the quick brown fox"
