---
"invalid conflicts fails":
  - do:
      index:
        index:   test
        id:      "1"
        body:    { "text": "test" }
  - do:
      catch: /conflicts may only be .* but was \[cat\]/
      update_by_query:
        index: test
        conflicts: cat

---
"invalid max_docs in URL fails":
  - requires:
      cluster_features: ["gte_v7.3.0"]
      reason: "max_docs introduced in 7.3.0"

  - do:
      index:
        index:   test
        id:      "1"
        body:    { "text": "test" }
  - do:
      catch: /\[max_docs\] parameter cannot be negative, found \[-4\]/
      update_by_query:
        index: test
        max_docs: -4

---
"invalid max_docs in body fails":
  - requires:
      cluster_features: ["gte_v7.3.0"]
      reason: "max_docs introduced in 7.3.0"

  - do:
      index:
        index:   test
        id:      "1"
        body:    { "text": "test" }
  - do:
      catch: /\[max_docs\] parameter cannot be negative, found \[-4\]/
      update_by_query:
        index: test
        body:
          max_docs: -4

---
"inconsistent max_docs in body and max_docs in URL fails":
  - requires:
      cluster_features: ["gte_v7.3.0"]
      reason: "max_docs introduced in 7.3.0"

  - do:
      index:
        index:   test
        id:      "1"
        body:    { "text": "test" }
  - do:
      catch: /\[max_docs\] set to two different values \[4\] and \[5\]/
      delete_by_query:
        index: test
        max_docs: 5
        body:
          max_docs: 4
          query:
            match_all: {}

---
"max_docs shoule be greater than slices":
  - requires:
      cluster_features: ["gte_v7.3.0"]
      reason: "max_docs introduced in 7.3.0"

  - do:
      index:
        index:   test
        id:      "1"
        body:    { "text": "test" }
  - do:
      catch: /\[max_docs\] should be >= \[slices\]/
      update_by_query:
        index: test
        max_docs: 1
        slices: 2

---
"invalid scroll_size fails":
  - do:
      index:
        index:   test
        id:      "1"
        body:    { "text": "test" }
  - do:
      catch: /Failed to parse int parameter \[scroll_size\] with value \[asdf\]/
      update_by_query:
        index: test
        scroll_size: asdf

---
"update_by_query without source gives useful error message":
  - do:
      indices.create:
        index: test
        body:
          mappings:
            _source:
              enabled: false
  - do:
      index:
        index:  test
        id:     "1"
        body:   { age: 23 }
  - do:
      indices.refresh: {}

  - do:
      catch: /\[test\]\[1\] didn't store _source/
      update_by_query:
        index: test

---
"source fields may not be modified":
  - do:
      catch: /stored_fields is not supported in this context/
      update_by_query:
        index: test
        body:
          stored_fields: [_id]

---
"requests_per_second cannot be an empty string":
  - do:
      catch: /\[requests_per_second\] must be a float greater than 0. Use -1 to disable throttling./
      update_by_query:
        requests_per_second: ""
        index: test

---
"requests_per_second cannot be negative":
  - do:
      catch: /\[requests_per_second\] must be a float greater than 0. Use -1 to disable throttling./
      update_by_query:
        requests_per_second: -12
        index: test

---
"requests_per_second cannot be zero":
  - do:
      catch: /\[requests_per_second\] must be a float greater than 0. Use -1 to disable throttling./
      update_by_query:
        requests_per_second: 0
        index: test

---
"requests_per_second cannot be unlimited":
  - do:
      catch: /\[requests_per_second\] must be a float greater than 0. Use -1 to disable throttling./
      update_by_query:
        requests_per_second: 0
        index: test

---
"junk in slices fails":
  - do:
      catch: /\[slices\] must be a positive integer or the string "auto"/
      update_by_query:
        slices: junk
        index: test

---
"zero slices fails":
  - do:
      catch: /\[slices\] must be a positive integer or the string "auto"/
      update_by_query:
        slices: 0
        index: test
---
"Remote indices are not allowed in update-by-query":
  - do:
      catch: bad_request
      update_by_query:
        index: "remote:test"
        body:
          query:
            match_all: {}
  - match: { status: 400 }
  - match: { error.type: "action_request_validation_exception" }
  - match: { error.reason: "Validation Failed: 1: Cross-cluster calls are not supported in this context but remote indices were requested: [remote:test];" }
