setup:
  - do:
      indices.create:
          index:  test_2
  - do:
      indices.create:
          index:  test_1
  - do:
      index:
          index:  test_1
          type:   test
          id:     1
          body:   { foo: bar }

  - do:
      index:
          index:  test_2
          type:   test
          id:     42
          body:   { foo: bar }

  - do:
      indices.refresh:
        index: [test_1, test_2]

---
"Basic search":

  - do:
      search:
        index: _all
        type:  test
        body:
          query:
            match:
              foo: bar

  - match: {hits.total: 2}

  - do:
      search:
        index: test_1
        type:  test
        body:
          query:
            match:
              foo: bar

  - match: {hits.total: 1}
  - match: {hits.hits.0._index: test_1 }
  - match: {hits.hits.0._type:  test   }
  - match: {hits.hits.0._id:    "1"    }

  - do:
      search:
        index: test_2
        type:  test
        body:
          query:
            match:
              foo: bar

  - match: {hits.total: 1}
  - match: {hits.hits.0._index: test_2 }
  - match: {hits.hits.0._type:  test   }
  - match: {hits.hits.0._id:    "42"   }

---
"Search body without query element":

    - do:
        catch: bad_request
        search:
          body:
            match:
              foo: bar

