---
"update_by_query increments the version number":
  - do:
      index:
        index:   test
        id:      "1"
        body:    {"text": "test"}
  - do:
      indices.refresh: {}

  - do:
      update_by_query:
        index: test
  - match: {updated: 1}
  - match: {version_conflicts: 0}

  - do:
      get:
        index: test
        id:    "1"
  - match: {_version: 2}

---
"update_by_query fails to update documents with version number equal to zero":
  - skip:
      cluster_features: ["gte_v6.7.0"]
      reason: reindex moved to rely on sequence numbers for concurrency control
  - do:
      index:
        index:        index1
        id:           "1"
        version:      0 # Starting version is zero
        version_type: external
        body:    {"update": 0}
  - do:
      indices.refresh: {}

  # Update by query uses internal versioning and will fail here
  # because zero is not allowed as a valid version number
  - do:
      catch: /illegal version value \[0\] for version type \[INTERNAL\]./
      update_by_query:
        index: index1
        refresh: true
  - do:
      get:
        index: index1
        id:    "1"
  - match: {_version: 0}
