---
setup:
- skip:
    features:
    - "headers"
    - "allowed_warnings_regex"
- requires:
    cluster_features: "gte_v8.12.0"
    reason: "ingest simulate added in 8.12"
---
Test no pipelines:
- skip:
    features: "headers"
- do:
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    simulate.ingest:
      body: "{\n  \"docs\": [\n    {\n      \"_index\": \"index-1\",\n      \"_id\"\
        : \"id\",\n      \"_source\": {\n        \"foo\": \"bar\"\n      }\n    },\n\
        \    {\n      \"_index\": \"index-2\",\n      \"_id\": \"id\",\n      \"_source\"\
        : {\n        \"foo\": \"rab\"\n      }\n    }\n  ]\n}\n"
    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:
    docs: 2
- match:
    docs.0.doc._index: "index-1"
- match:
    docs.0.doc._source.foo: "bar"
- match:
    docs.0.doc.executed_pipelines: []
- match:
    docs.1.doc._index: "index-2"
- match:
    docs.1.doc._source.foo: "rab"
- match:
    docs.1.doc.executed_pipelines: []
---
Test existing index with pipelines:
- skip:
    features: "headers"
- do:
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    ingest.put_pipeline:
      id: "my-pipeline"
      body: "{\n  \"processors\": [\n  ]\n}\n"
    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:
    acknowledged: true
- do:
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    ingest.put_pipeline:
      id: "my-final-pipeline"
      body: "{\n  \"processors\": [\n  ]\n}\n"
    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:
    acknowledged: true
- do:
    indices.create:
      index: "index"
      body:
        settings:
          default_pipeline: "my-pipeline"
          final_pipeline: "my-final-pipeline"
    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:
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    simulate.ingest:
      body: "{\n  \"docs\": [\n    {\n      \"_index\": \"index\",\n      \"_id\"\
        : \"id\",\n      \"_source\": {\n        \"foo\": \"bar\"\n      }\n    },\n\
        \    {\n      \"_index\": \"index\",\n      \"_id\": \"id\",\n      \"_source\"\
        : {\n        \"foo\": \"rab\"\n      }\n    }\n  ],\n  \"pipeline_substitutions\"\
        : {\n    \"my-pipeline\": {\n      \"processors\": [\n      ]\n    }\n  }\n\
        }\n"
    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:
    docs: 2
- match:
    docs.0.doc._source.foo: "bar"
- match:
    docs.0.doc.executed_pipelines:
    - "my-pipeline"
    - "my-final-pipeline"
- match:
    docs.1.doc._source.foo: "rab"
- match:
    docs.1.doc.executed_pipelines:
    - "my-pipeline"
    - "my-final-pipeline"
---
Test mapping validation:
- skip:
    features: "headers"
- requires:
    cluster_features:
    - "simulate.mapping.validation"
    reason: "ingest simulate index mapping validation added in 8.16"
- do:
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    ingest.put_pipeline:
      id: "my-pipeline"
      body: "{\n  \"processors\": [\n  ]\n}\n"
    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:
    acknowledged: true
- do:
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    ingest.put_pipeline:
      id: "my-final-pipeline"
      body: "{\n  \"processors\": [\n  ]\n}\n"
    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:
    acknowledged: true
- do:
    indices.create:
      index: "strict_index"
      body:
        settings:
          default_pipeline: "my-pipeline"
          final_pipeline: "my-final-pipeline"
          number_of_shards: 2
          number_of_replicas: 0
        mappings:
          dynamic: "strict"
          properties:
            foo:
              type: "text"
    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:
    indices.create:
      index: "lenient_index"
      body:
        settings:
          default_pipeline: "my-pipeline"
          final_pipeline: "my-final-pipeline"
          number_of_shards: 2
          number_of_replicas: 0
        mappings:
          dynamic: true
          properties:
            foo:
              type: "text"
    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:
    cluster.health:
      index: "lenient_index"
      wait_for_status: "green"
    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:
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    simulate.ingest:
      body: "{\n  \"docs\": [\n    {\n      \"_index\": \"strict_index\",\n      \"\
        _id\": \"id\",\n      \"_source\": {\n        \"foob\": \"bar\"\n      }\n\
        \    },\n    {\n      \"_index\": \"strict_index\",\n      \"_id\": \"id\"\
        ,\n      \"_source\": {\n        \"foo\": \"rab\"\n      }\n    }\n  ],\n\
        \  \"pipeline_substitutions\": {\n    \"my-pipeline\": {\n      \"processors\"\
        : [\n      ]\n    }\n  }\n}\n"
    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:
    docs: 2
- match:
    docs.0.doc._source.foob: "bar"
- match:
    docs.0.doc.executed_pipelines:
    - "my-pipeline"
    - "my-final-pipeline"
- match:
    docs.0.doc.error.type: "strict_dynamic_mapping_exception"
- match:
    docs.0.doc.error.reason: "[1:9] mapping set to strict, dynamic introduction of\
      \ [foob] within [_doc] is not allowed"
- match:
    docs.1.doc._source.foo: "rab"
- match:
    docs.1.doc.executed_pipelines:
    - "my-pipeline"
    - "my-final-pipeline"
- not_exists: "docs.1.doc.error"
- do:
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    simulate.ingest:
      body: "{\n  \"docs\": [\n    {\n      \"_index\": \"lenient_index\",\n     \
        \ \"_id\": \"id\",\n      \"_source\": {\n        \"foob\": \"bar\"\n    \
        \  }\n    },\n    {\n      \"_index\": \"lenient_index\",\n      \"_id\":\
        \ \"id\",\n      \"_source\": {\n        \"foo\": \"rab\"\n      }\n    }\n\
        \  ],\n  \"pipeline_substitutions\": {\n    \"my-pipeline\": {\n      \"processors\"\
        : [\n      ]\n    }\n  }\n}\n"
    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:
    docs: 2
- match:
    docs.0.doc._source.foob: "bar"
- match:
    docs.0.doc.executed_pipelines:
    - "my-pipeline"
    - "my-final-pipeline"
- not_exists: "docs.0.doc.error"
- match:
    docs.1.doc._source.foo: "rab"
- match:
    docs.1.doc.executed_pipelines:
    - "my-pipeline"
    - "my-final-pipeline"
- not_exists: "docs.1.doc.error"
---
Test mapping validation from templates:
- skip:
    features:
    - "headers"
    - "allowed_warnings"
- requires:
    cluster_features:
    - "simulate.mapping.validation.templates"
    reason: "ingest simulate index mapping validation added in 8.16"
- do:
    indices.put_template:
      name: "v1_template"
      body:
        index_patterns: "v1_strict_nonexistent*"
        mappings:
          dynamic: "strict"
          properties:
            foo:
              type: "text"
    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:
    allowed_warnings:
    - "index template [v2_template] has index patterns [v2_strict_nonexistent*] matching\
      \ patterns from existing older templates [global] with patterns (global => [*]);\
      \ this template [v2_template] will take precedence during new index creation"
    indices.put_index_template:
      name: "v2_template"
      body:
        index_patterns: "v2_strict_nonexistent*"
        template:
          mappings:
            dynamic: "strict"
            properties:
              foo:
                type: "text"
    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:
    allowed_warnings:
    - "index template [v2_hidden_template] has index patterns [v2_strict_hidden_nonexistent*]\
      \ matching patterns from existing older templates [global] with patterns (global\
      \ => [*]); this template [v2_hidden_template] will take precedence during new\
      \ index creation"
    indices.put_index_template:
      name: "v2_hidden_template"
      body:
        index_patterns: "v2_strict_hidden_nonexistent*"
        template:
          settings:
            index:
              hidden: true
          mappings:
            dynamic: "strict"
            properties:
              foo:
                type: "text"
    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:
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    simulate.ingest:
      body: "{\n  \"docs\": [\n    {\n      \"_index\": \"v1_strict_nonexistent_index\"\
        ,\n      \"_id\": \"id\",\n      \"_source\": {\n        \"foob\": \"bar\"\
        \n      }\n    },\n    {\n      \"_index\": \"v1_strict_nonexistent_index\"\
        ,\n      \"_id\": \"id\",\n      \"_source\": {\n        \"foo\": \"rab\"\n\
        \      }\n    }\n  ],\n  \"pipeline_substitutions\": {\n    \"my-pipeline\"\
        : {\n      \"processors\": [\n      ]\n    }\n  }\n}\n"
    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:
    docs: 2
- match:
    docs.0.doc._source.foob: "bar"
- match:
    docs.0.doc.error.type: "strict_dynamic_mapping_exception"
- match:
    docs.0.doc.error.reason: "[1:9] mapping set to strict, dynamic introduction of\
      \ [foob] within [_doc] is not allowed"
- match:
    docs.1.doc._source.foo: "rab"
- not_exists: "docs.1.doc.error"
- do:
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    simulate.ingest:
      body: "{\n  \"docs\": [\n    {\n      \"_index\": \"v2_strict_nonexistent_index\"\
        ,\n      \"_id\": \"id\",\n      \"_source\": {\n        \"foob\": \"bar\"\
        \n      }\n    },\n    {\n      \"_index\": \"v2_strict_nonexistent_index\"\
        ,\n      \"_id\": \"id\",\n      \"_source\": {\n        \"foo\": \"rab\"\n\
        \      }\n    },\n    {\n      \"_index\": \"v2_strict_hidden_nonexistent_index\"\
        ,\n      \"_id\": \"id\",\n      \"_source\": {\n        \"foob\": \"bar\"\
        \n      }\n    }\n  ],\n  \"pipeline_substitutions\": {\n    \"my-pipeline\"\
        : {\n      \"processors\": [\n      ]\n    }\n  }\n}\n"
    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:
    docs: 3
- match:
    docs.0.doc._source.foob: "bar"
- match:
    docs.0.doc.error.type: "strict_dynamic_mapping_exception"
- match:
    docs.0.doc.error.reason: "[1:9] mapping set to strict, dynamic introduction of\
      \ [foob] within [_doc] is not allowed"
- match:
    docs.1.doc._source.foo: "rab"
- not_exists: "docs.1.doc.error"
- match:
    docs.2.doc._source.foob: "bar"
- match:
    docs.2.doc.error.type: "strict_dynamic_mapping_exception"
- match:
    docs.2.doc.error.reason: "[1:9] mapping set to strict, dynamic introduction of\
      \ [foob] within [_doc] is not allowed"
---
Test mapping validation for data streams from templates:
- skip:
    features:
    - "headers"
    - "allowed_warnings"
- requires:
    cluster_features:
    - "simulate.mapping.validation.templates"
    reason: "ingest simulate index mapping validation added in 8.16"
- do:
    allowed_warnings:
    - "index template [my-template1] has index patterns [simple-data-stream1] matching\
      \ patterns from existing older templates [global] with patterns (global => [*]);\
      \ this template [my-template1] will take precedence during new index creation"
    indices.put_index_template:
      name: "my-template1"
      body:
        index_patterns:
        - "simple-data-stream1"
        template:
          settings:
            index.number_of_replicas: 1
          mappings:
            dynamic: "strict"
            properties:
              foo:
                type: "text"
        data_stream: {}
    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:
    allowed_warnings:
    - "index template [my-hidden-template1] has index patterns [simple-hidden-data-stream1]\
      \ matching patterns from existing older templates [global] with patterns (global\
      \ => [*]); this template [my-hidden-template1] will take precedence during new\
      \ index creation"
    indices.put_index_template:
      name: "my-hidden-template1"
      body:
        index_patterns:
        - "simple-hidden-data-stream1"
        template:
          settings:
            index.number_of_replicas: 1
          mappings:
            dynamic: "strict"
            properties:
              foo:
                type: "text"
        data_stream:
          hidden: true
    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:
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    simulate.ingest:
      body: "{\n  \"docs\": [\n    {\n      \"_index\": \"simple-data-stream1\",\n\
        \      \"_id\": \"id\",\n      \"_source\": {\n        \"@timestamp\": \"\
        2020-12-12\",\n        \"foob\": \"bar\"\n      }\n    },\n    {\n      \"\
        _index\": \"simple-data-stream1\",\n      \"_id\": \"id\",\n      \"_source\"\
        : {\n        \"@timestamp\": \"2020-12-12\",\n        \"foo\": \"rab\"\n \
        \     }\n    },\n    {\n      \"_index\": \"simple-hidden-data-stream1\",\n\
        \      \"_id\": \"id\",\n      \"_source\": {\n        \"@timestamp\": \"\
        2020-12-12\",\n        \"foob\": \"bar\"\n      }\n    }\n  ],\n  \"pipeline_substitutions\"\
        : {\n    \"my-pipeline\": {\n      \"processors\": [\n      ]\n    }\n  }\n\
        }\n"
    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:
    docs: 3
- match:
    docs.0.doc._source.foob: "bar"
- match:
    docs.0.doc.error.type: "strict_dynamic_mapping_exception"
- match:
    docs.0.doc.error.reason: "[1:35] mapping set to strict, dynamic introduction of\
      \ [foob] within [_doc] is not allowed"
- match:
    docs.1.doc._source.foo: "rab"
- not_exists: "docs.1.doc.error"
- match:
    docs.2.doc._source.foob: "bar"
- match:
    docs.2.doc.error.type: "strict_dynamic_mapping_exception"
- match:
    docs.2.doc.error.reason: "[1:35] mapping set to strict, dynamic introduction of\
      \ [foob] within [_doc] is not allowed"
- do:
    indices.create_data_stream:
      name: "simple-data-stream1"
    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"
- is_true: "acknowledged"
- do:
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    simulate.ingest:
      body: "{\n  \"docs\": [\n    {\n      \"_index\": \"simple-data-stream1\",\n\
        \      \"_id\": \"id\",\n      \"_source\": {\n        \"@timestamp\": \"\
        2020-12-12\",\n        \"foob\": \"bar\"\n      }\n    },\n    {\n      \"\
        _index\": \"simple-data-stream1\",\n      \"_id\": \"id\",\n      \"_source\"\
        : {\n        \"@timestamp\": \"2020-12-12\",\n        \"foo\": \"rab\"\n \
        \     }\n    }\n  ],\n  \"pipeline_substitutions\": {\n    \"my-pipeline\"\
        : {\n      \"processors\": [\n      ]\n    }\n  }\n}\n"
    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:
    docs: 2
- match:
    docs.0.doc._source.foob: "bar"
- match:
    docs.0.doc.error.type: "strict_dynamic_mapping_exception"
- match:
    docs.0.doc.error.reason: "[1:35] mapping set to strict, dynamic introduction of\
      \ [foob] within [_doc] is not allowed"
- match:
    docs.1.doc._source.foo: "rab"
- not_exists: "docs.1.doc.error"
---
Test index templates with pipelines:
- skip:
    features:
    - "headers"
    - "allowed_warnings"
- do:
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    ingest.put_pipeline:
      id: "my-pipeline"
      body: "{\n  \"processors\": [\n  ]\n}\n"
    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:
    acknowledged: true
- do:
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    ingest.put_pipeline:
      id: "my-final-pipeline"
      body: "{\n  \"processors\": [\n  ]\n}\n"
    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:
    acknowledged: true
- do:
    allowed_warnings:
    - "index template [my-template] has index patterns [index-*] matching patterns\
      \ from existing older templates [global] with patterns (global => [*]); this\
      \ template [my-template] will take precedence during new index creation"
    indices.put_index_template:
      name: "my-template"
      body:
        index_patterns: "index-*"
        template:
          settings:
            default_pipeline: "my-pipeline"
            final_pipeline: "my-final-pipeline"
    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:
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    simulate.ingest:
      body: "{\n  \"docs\": [\n    {\n      \"_index\": \"index-1\",\n      \"_id\"\
        : \"id\",\n      \"_source\": {\n        \"foo\": \"bar\"\n      }\n    },\n\
        \    {\n      \"_index\": \"index-1\",\n      \"_id\": \"id\",\n      \"_source\"\
        : {\n        \"foo\": \"rab\"\n      }\n    }\n  ],\n  \"pipeline_substitutions\"\
        : {\n    \"my-pipeline\": {\n      \"processors\": [\n      ]\n    }\n  }\n\
        }\n"
    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:
    docs: 2
- match:
    docs.0.doc._index: "index-1"
- match:
    docs.0.doc._source.foo: "bar"
- match:
    docs.0.doc.executed_pipelines:
    - "my-pipeline"
    - "my-final-pipeline"
- match:
    docs.1.doc._index: "index-1"
- match:
    docs.1.doc._source.foo: "rab"
- match:
    docs.1.doc.executed_pipelines:
    - "my-pipeline"
    - "my-final-pipeline"
---
Test index in path:
- skip:
    features: "headers"
- do:
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    simulate.ingest:
      index: "test-index"
      body: "{\n  \"docs\": [\n    {\n      \"_id\": \"id\",\n      \"_source\": {\n\
        \        \"foo\": \"bar\"\n      }\n    },\n    {\n      \"_id\": \"id\",\n\
        \      \"_source\": {\n        \"foo\": \"rab\"\n      }\n    }\n  ]\n}\n"
    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:
    docs: 2
- match:
    docs.0.doc._index: "test-index"
- match:
    docs.0.doc._source.foo: "bar"
- match:
    docs.0.doc.executed_pipelines: []
- match:
    docs.1.doc._index: "test-index"
- match:
    docs.1.doc._source.foo: "rab"
- match:
    docs.1.doc.executed_pipelines: []
---
Test pipeline in query param:
- skip:
    features: "headers"
- do:
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    ingest.put_pipeline:
      id: "my-pipeline"
      body: "{\n  \"processors\": [\n  ]\n}\n"
    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:
    acknowledged: true
- do:
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    simulate.ingest:
      pipeline: "my-pipeline"
      body: "{\n  \"docs\": [\n    {\n      \"_index\": \"index-1\",\n      \"_id\"\
        : \"id\",\n      \"_source\": {\n        \"foo\": \"bar\"\n      }\n    },\n\
        \    {\n      \"_index\": \"index-2\",\n      \"_id\": \"id\",\n      \"_source\"\
        : {\n        \"foo\": \"rab\"\n      }\n    }\n  ]\n}\n"
    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:
    docs: 2
- match:
    docs.0.doc._index: "index-1"
- match:
    docs.0.doc._source.foo: "bar"
- match:
    docs.0.doc.executed_pipelines:
    - "my-pipeline"
- match:
    docs.1.doc._index: "index-2"
- match:
    docs.1.doc._source.foo: "rab"
- match:
    docs.1.doc.executed_pipelines:
    - "my-pipeline"
