---
setup:
- skip:
    features:
    - "headers"
    - "allowed_warnings_regex"
- requires:
    cluster_features:
    - "gte_v8.10.0"
    reason: "Introduced in 8.10.0"
- do:
    synonyms.put_synonym:
      id: "test-synonyms"
      body:
        synonyms_set:
        - synonyms: "hello, hi"
          id: "test-id-1"
        - synonyms: "bye => goodbye"
          id: "test-id-2"
        - synonyms: "test => check"
          id: "test-id-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:
    cluster.health:
      index: ".synonyms-2"
      timeout: "2s"
      wait_for_status: "green"
      ignore: 408
    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"
---
Update a synonyms rule:
- do:
    synonyms.put_synonym_rule:
      set_id: "test-synonyms"
      rule_id: "test-id-2"
      body:
        synonyms: "bye, goodbye, seeya"
    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:
    result: "updated"
- match:
    reload_analyzers_details._shards.total: 0
- length:
    reload_analyzers_details.reload_details: 0
- do:
    synonyms.get_synonym:
      id: "test-synonyms"
    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:
    synonyms_set:
    - synonyms: "hello, hi"
      id: "test-id-1"
    - synonyms: "bye, goodbye, seeya"
      id: "test-id-2"
    - synonyms: "test => check"
      id: "test-id-3"
---
Create a new synonym rule:
- do:
    synonyms.put_synonym_rule:
      set_id: "test-synonyms"
      rule_id: "test-id-0"
      body:
        synonyms: "i-phone, iphone"
    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:
    result: "created"
- match:
    reload_analyzers_details._shards.total: 0
- length:
    reload_analyzers_details.reload_details: 0
- do:
    synonyms.get_synonym:
      id: "test-synonyms"
    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:
    synonyms_set:
    - synonyms: "i-phone, iphone"
      id: "test-id-0"
    - synonyms: "hello, hi"
      id: "test-id-1"
    - synonyms: "bye => goodbye"
      id: "test-id-2"
    - synonyms: "test => check"
      id: "test-id-3"
---
Update synonym rule for non existing synonym set:
- do:
    catch: "missing"
    synonyms.put_synonym_rule:
      set_id: "test-synonyms-non-existent"
      rule_id: "test-id-0"
      body:
        synonyms: "i-phone, iphone"
    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"
