setup:
  - do:
      index:
        index:  test_1
        type:   test
        id:     1
        body:   { "include": { "field1": "v1", "field2": "v2" }, "count": 1 }
  - do:
      index:
        index:  test_1
        type:   test
        id:     2
        body:   { "include": { "field1": "v1", "field2": "v2" }, "count": 1 }

---
"Source filtering -  true/false":

  - do:
      mget:
        body:
            docs:
              - { _index:  "test_1", _type: "test", _id: "1", _source: false }
              - { _index:  "test_1", _type: "test", _id: "2", _source: true }

  - match:   { docs.0._id: "1" }
  - is_false:  docs.0._source
  - match:   { docs.1._id: "2" }
  - is_true:   docs.1._source

---
"Source filtering -  include field":

  - do:
      mget:
        body:
          docs:
            - { _index:  "test_1", _type: "test", _id: "1", _source: include.field1 }
            - { _index:  "test_1", _type: "test", _id: "2", _source: [ include.field1 ] }

  - match:   { docs.0._source: { include: { field1: v1 }} }
  - match:   { docs.1._source: { include: { field1: v1 }} }


---
"Source filtering -  include nested field":

  - do:
      mget:
        body:
          docs:
            - { _index:  "test_1", _type: "test", _id: "1", _source: { include: include.field1 }  }
            - { _index:  "test_1", _type: "test", _id: "2", _source: { include: [ include.field1 ] } }

  - match:   { docs.0._source: { include: { field1: v1 }} }
  - match:   { docs.1._source: { include: { field1: v1 }} }

---
"Source filtering -  exclude field":

  - do:
      mget:
        body:
          docs:
            - { _index:  "test_1", _type: "test", _id: "1", _source: { include: [ include ], exclude: [ "*.field2" ] } }

  - match:   { docs.0._source: { include: { field1: v1 }} }

---
"Source filtering -  ids and true/false":

  - do:
      mget:
        _source: false
        index: test_1
        body: { ids: [ 1,2 ] }
  - is_false:   docs.0._source
  - is_false:   docs.1._source

  - do:
      mget:
        _source: true
        index: test_1
        body: { ids: [ 1,2 ] }
  - is_true:   docs.0._source
  - is_true:   docs.1._source

---
"Source filtering -  ids and include field":

  - do:
      mget:
        _source: include.field1
        index: test_1
        body: { ids: [ 1,2 ] }
  - match:   { docs.0._source: { include: { field1: v1 }} }
  - match:   { docs.1._source: { include: { field1: v1 }} }

---
"Source filtering -  ids and include nested field":

  - do:
      mget:
        _source_include: "include.field1,count"
        index: test_1
        body: { ids: [ 1,2 ] }
  - match:   { docs.0._source: { include: { field1: v1 }, count: 1} }
  - match:   { docs.1._source: { include: { field1: v1 }, count: 1} }

---
"Source filtering -  ids and exclude field":

  - do:
      mget:
        _source_include: include
        _source_exclude: "*.field2"
        index: test_1
        body: { ids: [ 1,2 ] }
  - match:   { docs.0._source: { include: { field1: v1 } } }
  - match:   { docs.1._source: { include: { field1: v1 } } }
