---
setup:

  - do:
      index:
          index:  index_1
          type:   test
          id:     1
          body:   { foo: bar }

  - do:
      index:
          index:  index_1
          type:   test
          id:     2
          body:   { foo: baz }

  - do:
      index:
          index:  index_1
          type:   test
          id:     3
          body:   { foo: foo }

  - do:
      index:
          index:  index_2
          type:   test
          id:     1
          body:   { foo: foo }

  - do:
      indices.refresh: {}

---
"Basic multi-search":

  - do:
      msearch:
        body:
          - index: index_*
          - query:
              match: {foo: foo}
          - index: index_2
          - query:
              match_all: {}
          - index: index_1
          - query:
              match: {foo: foo}
          - index: index_3
          - query:
              match_all: {}
          - type: test
          - query:
              match_all: {}

  - match:  { responses.0.hits.total:     2  }
  - match:  { responses.1.hits.total:     1  }
  - match:  { responses.2.hits.total:     1  }
  - match:  { responses.3.error.root_cause.0.type: index_not_found_exception }
  - match:  { responses.3.error.root_cause.0.reason: "/no.such.index/" }
  - match:  { responses.3.error.root_cause.0.index: index_3 }
  - match:  { responses.4.hits.total:     4  }
