---
setup:
- skip:
    features:
    - "headers"
    - "allowed_warnings_regex"
- requires:
    cluster_features:
    - "mapper.source.mode_from_index_setting"
    reason: "Source mode configured through index setting"
---
keyword:
- requires:
    cluster_features:
    - "gte_v8.4.0"
    reason: "introduced in 8.4.0"
- do:
    indices.create:
      index: "test"
      body:
        settings:
          index:
            mapping.source.mode: "synthetic"
        mappings:
          properties:
            kwd:
              type: "keyword"
    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"
      id: 1
      body:
        kwd: "foo"
    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"
      id: 2
      body:
        kwd: "bar"
    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:
    mget:
      index: "test"
      body:
        ids:
        - 1
        - 2
    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:
    docs.0._index: "test"
- match:
    docs.0._id: "1"
- match:
    docs.0._source:
      kwd: "foo"
- match:
    docs.1._index: "test"
- match:
    docs.1._id: "2"
- match:
    docs.1._source:
      kwd: "bar"
---
keyword with normalizer:
- requires:
    cluster_features:
    - "mapper.keyword_normalizer_synthetic_source"
    reason: "support for normalizer on keyword fields"
- do:
    indices.create:
      index: "test-keyword-with-normalizer"
      body:
        settings:
          analysis:
            normalizer:
              lowercase:
                type: "custom"
                filter:
                - "lowercase"
          index:
            mapping.source.mode: "synthetic"
        mappings:
          properties:
            keyword:
              type: "keyword"
              normalizer: "lowercase"
            keyword_with_ignore_above:
              type: "keyword"
              normalizer: "lowercase"
              ignore_above: 10
            keyword_without_doc_values:
              type: "keyword"
              normalizer: "lowercase"
              doc_values: false
    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-keyword-with-normalizer"
      id: 1
      body:
        keyword: "the Quick Brown Fox jumps over the lazy Dog"
        keyword_with_ignore_above: "the Quick Brown Fox jumps over the lazy Dog"
        keyword_without_doc_values: "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:
    index:
      index: "test-keyword-with-normalizer"
      id: 2
      body:
        keyword: "The five BOXING wizards jump Quickly"
        keyword_with_ignore_above: "The five BOXING wizards jump Quickly"
        keyword_without_doc_values: "The five BOXING wizards jump Quickly"
    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-keyword-with-normalizer"
      id: 3
      body:
        keyword:
        - "May the FORCE be with You!"
        - "Do or Do Not, There is no Try"
        keyword_with_ignore_above:
        - "May the FORCE be with You!"
        - "Do or Do Not, There is no Try"
        keyword_without_doc_values:
        - "May the FORCE be with You!"
        - "Do or Do Not, There is no Try"
    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:
    mget:
      index: "test-keyword-with-normalizer"
      body:
        ids:
        - 1
        - 2
        - 3
    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:
    docs.0._index: "test-keyword-with-normalizer"
- match:
    docs.0._id: "1"
- match:
    docs.0._source:
      keyword: "the Quick Brown Fox jumps over the lazy Dog"
      keyword_with_ignore_above: "the Quick Brown Fox jumps over the lazy Dog"
      keyword_without_doc_values: "the Quick Brown Fox jumps over the lazy Dog"
- match:
    docs.1._index: "test-keyword-with-normalizer"
- match:
    docs.1._id: "2"
- match:
    docs.1._source:
      keyword: "The five BOXING wizards jump Quickly"
      keyword_with_ignore_above: "The five BOXING wizards jump Quickly"
      keyword_without_doc_values: "The five BOXING wizards jump Quickly"
- match:
    docs.2._index: "test-keyword-with-normalizer"
- match:
    docs.2._id: "3"
- match:
    docs.2._source:
      keyword:
      - "May the FORCE be with You!"
      - "Do or Do Not, There is no Try"
      keyword_with_ignore_above:
      - "May the FORCE be with You!"
      - "Do or Do Not, There is no Try"
      keyword_without_doc_values:
      - "May the FORCE be with You!"
      - "Do or Do Not, There is no Try"
---
stored text:
- requires:
    cluster_features:
    - "gte_v8.5.0"
    reason: "introduced in 8.5.0"
- do:
    indices.create:
      index: "test"
      body:
        settings:
          index:
            mapping.source.mode: "synthetic"
        mappings:
          properties:
            text:
              type: "text"
              store: 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:
    index:
      index: "test"
      id: 1
      body:
        text: "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:
    index:
      index: "test"
      id: 2
      body:
        text: "jumped 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:
    mget:
      index: "test"
      body:
        ids:
        - 1
        - 2
    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:
    docs.0._index: "test"
- match:
    docs.0._id: "1"
- match:
    docs.0._source:
      text: "the quick brown fox"
- match:
    docs.1._index: "test"
- match:
    docs.1._id: "2"
- match:
    docs.1._source:
      text: "jumped over the lazy dog"
---
force_synthetic_source_ok:
- requires:
    cluster_features:
    - "gte_v8.4.0"
    reason: "introduced in 8.4.0"
- do:
    indices.create:
      index: "test"
      body:
        settings:
          index:
            mapping.source.mode: "stored"
        mappings:
          properties:
            obj:
              properties:
                kwd:
                  type: "keyword"
    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"
      id: 1
      body:
        obj.kwd: "foo"
    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"
      id: 2
      body:
        obj:
          kwd: "bar"
    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:
    mget:
      index: "test"
      body:
        ids:
        - 1
        - 2
    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:
    docs.0._source:
      obj.kwd: "foo"
- match:
    docs.1._source:
      obj:
        kwd: "bar"
- do:
    mget:
      index: "test"
      force_synthetic_source: true
      body:
        ids:
        - 1
        - 2
    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:
    docs.0._source:
      obj:
        kwd: "foo"
- match:
    docs.1._source:
      obj:
        kwd: "bar"
