---
"Can limit copied docs by specifying a query":
  - do:
      index:
        index:  test
        type:   test
        id:     1
        body:   { "text": "test" }
  - do:
      index:
        index:  test
        type:   test
        id:     2
        body:   { "text": "junk" }
  - do:
      indices.refresh: {}

  - do:
      reindex:
        refresh: true
        body:
          source:
            index: test
            query:
              match:
                text: test
          dest:
            index: target

  - do:
      search:
        index: target
  - match: { hits.total: 1 }

---
"Sorting and size combined":
  - do:
      index:
        index:  test
        type:   test
        id:     1
        body:   { "order": 1 }
  - do:
      index:
        index:  test
        type:   test
        id:     2
        body:   { "order": 2 }
  - do:
      indices.refresh: {}

  - do:
      reindex:
        refresh: true
        body:
          size: 1
          source:
            index: test
            sort: order
          dest:
            index: target

  - do:
      search:
        index: target
  - match: { hits.total: 1 }

  - do:
      search:
        index: target
        q: order:1
  - match: { hits.total: 1 }
