---
"Refresh":

 - do:
      indices.create:
          index:    test_1
          body:
              settings:
                  refresh_interval: -1
                  number_of_shards: 5
                  number_of_replicas: 0
 - do:
      cluster.health:
          wait_for_status: green

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

# If you wonder why this document get 3 as an id instead of 2, it is because the
# current routing algorithm would route 1 and 2 to the same shard while we need
# them to be different for this test to pass
 - do:
      index:
          index:   test_1
          type:    test
          id:      3
          body:    { foo: bar }
          refresh: 1

 - do:
      search:
          index:   test_1
          type:    test
          body:
            query:   { terms: { _id: [1,3] }}

 - match: { hits.total: 2 }

 - do:
      delete:
          index:   test_1
          type:    test
          id:      1

 - do:
      search:
          index:   test_1
          type:    test
          body:
            query:   { terms: { _id: [1,3] }}

 - match: { hits.total: 2 }

 - do:
      delete:
          index:   test_1
          type:    test
          id:      3
          refresh: 1

# If a replica shard where doc 1 is located gets initialized at this point, doc 1
# won't be found by the following search as the shard gets automatically refreshed
# right before getting started. This is why this test only works with 0 replicas.

 - do:
      search:
          index:   test_1
          type:    test
          body:
            query:   { terms: { _id: [1,3] }}

 - match: { hits.total: 1 }