---
"Multi keyword and unsigned_long fields":
  - requires:
      cluster_features: ["gte_v7.10.0"]
      reason: "unsigned_long was added in 7.10"

  - do:
      indices.create:
        index:  test1
        body:
          mappings:
            properties:
              counter:
                type: keyword
                fields:
                  ul:
                    type: unsigned_long

  - do:
      bulk:
        index: test1
        refresh: true
        body: |
          { "index": {"_id" : "1"} }
          { "counter": 0 }
          { "index": {"_id" : "2"} }
          { "counter": 9223372036854775808 }
          { "index": {"_id" : "3"} }
          { "counter": "9223372036854775808" }
          { "index": {"_id" : "4"} }
          { "counter": 18446744073709551614 }
          { "index": {"_id" : "5"} }
          { "counter": 18446744073709551615 }

  # term query
  - do:
      search:
        index: test1
        body:
          query:
            term:
              counter.ul: 9223372036854775808
  - match: { "hits.total.value": 2 }
  - match: {hits.hits.0._id: "2" }
  - match: {hits.hits.1._id: "3" }


  # asc sort by keyword
  - do:
      search:
        index: test1
        body:
          sort: { counter : { order: asc} }
  - match: { "hits.total.value": 5 }
  - match: {hits.hits.0._id: "1" }
  - match: {hits.hits.1._id: "4" }
  - match: {hits.hits.2._id: "5" }
  - match: {hits.hits.3._id: "2" }
  - match: {hits.hits.4._id: "3" }

  # asc sort by unsigned long
  - do:
      search:
        index: test1
        body:
          sort: { counter.ul: { order: asc} }
  - match: { "hits.total.value": 5 }
  - match: {hits.hits.0._id: "1" }
  - match: {hits.hits.1._id: "2" }
  - match: {hits.hits.2._id: "3" }
  - match: {hits.hits.3._id: "4" }
  - match: {hits.hits.4._id: "5" }
