---
setup:
- skip:
    features:
    - "headers"
    - "allowed_warnings_regex"
- do:
    indices.create:
      index: "test-index"
      body:
        settings:
          number_of_shards: 1
        mappings:
          properties:
            k1:
              type: "keyword"
            k2:
              type: "keyword"
              ignore_above: 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"
- do:
    bulk:
      index: "test-index"
      refresh: true
      body:
      - "{\"index\": {\"_id\": \"1\"}}"
      - "{\"k1\": \"123\", \"k2\" : \"123\"}"
      - "{\"index\": {\"_id\": \"2\"}}"
      - "{\"k1\": \"1234\", \"k2\" : \"1234\"}"
    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"
---
Plain Highligher should skip highlighting ignored keyword values:
- requires:
    cluster_features:
    - "gte_v7.7.0"
    reason: "skip highlighting of ignored values was introduced in 7.7"
- do:
    search:
      index: "test-index"
      body:
        query:
          prefix:
            k1: "12"
        highlight:
          require_field_match: false
          fields:
            k2:
              type: "plain"
    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:
    hits.hits.0.highlight.k2.0: "<em>123</em>"
- is_false: "hits.hits.1.highlight"
---
Unified Highligher should skip highlighting ignored keyword values:
- requires:
    cluster_features:
    - "gte_v7.7.0"
    reason: "skip highlighting of ignored values was introduced in 7.7"
- do:
    search:
      index: "test-index"
      body:
        query:
          prefix:
            k1: "12"
        highlight:
          require_field_match: false
          fields:
            k2:
              type: "unified"
    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:
    hits.hits.0.highlight.k2.0: "<em>123</em>"
- is_false: "hits.hits.1.highlight"
