anchor.diff:  [[_using_date_math_with_the_rollover_api]]
   ===== Use date math with a rollover
   
  -It can be useful to use <<date-math-index-names,date math>> to name the
  -rollover index according to the date that the index rolled over, e.g.
  +If the rollover target is an index alias, it can be useful to use <<date-math-index-names,date math>>
  +to name the rollover index according to the date that the index rolled over, e.g.
   `logstash-2016.02.03`.  The rollover API supports date math, but requires the
  -index name to end with a dash followed by a number, e.g.
  -`logstash-2016.02.03-1` which is incremented every time the index is rolled
  -over. For instance:
  +index name to end with a dash followed by a number, e.g. `logstash-2016.02.03-1`
  +which is incremented every time the index is rolled over. For instance:
   
   [source,console]
   --------------------------------------------------
  
positive.code: 
  `max_size`::
  (Optional, <<byte-units, byte units>>)
  Maximum index size. 
  This is the total size of all primary shards in the index. 
  Replicas are not counted toward the maximum index size.
  
  TIP: To see the current index size, use the <<cat-indices, _cat indices>> API. 
  The `pri.store.size` value shows the combined size of all primary shards. 
  --
  
  include::{docdir}/rest-api/common-parms.asciidoc[tag=mappings]
  
negative.code: <2> Whether the rollover was dry run.
  <3> The result of each condition.
  
  
  [[rollover-data-stream-ex]]
  ===== Roll over a data stream
  
  [source,console]
  --------------------------------------------------
  PUT /_data_stream/my-data-stream <1>
  {
    "timestamp_field": "date"
  }
  
  # Add > 1000 documents to my-data-stream
  
  POST /my-data-stream/_rollover <2>
  {
    "conditions" : {
    "max_age": "7d",
    "max_docs": 1000,
    "max_size": "5gb"
    }
  }
  --------------------------------------------------
  // TEST[setup:huge_twitter]
  // TEST[s/# Add > 1000 documents to my-data-stream/POST _reindex?refresh\n{"source":{"index":"twitter"},"dest":{"index":"my-data-stream-000001"}}/]
  <1> Creates a data stream called `my-data-stream` with one initial backing index
  named `my-data-stream-000001`.
  <2> This request creates a new backing index, `my-data-stream-000002`, and adds
  it as the write index for the `my-data-stream` data stream if the current
  write index meets at least one of the following conditions:
  +
  --
  * The index was created 7 or more days ago.
  * The index has an index size of 5GB or greater.
  * The index contains 1,000 or more documents.
  --
  
  The API returns the following response:
  
  [source,console-result]
  --------------------------------------------------
  {
    "acknowledged": true,
    "shards_acknowledged": true,
    "old_index": "my-data-stream-000001", <1>
    "new_index": "my-data-stream-000002", <2>
    "rolled_over": true, <3>
    "dry_run": false, <4>
    "conditions": { <5>
      "[max_age: 7d]": false,
      "[max_docs: 1000]": true,
      "[max_size: 5gb]": false,
    }
  }
  --------------------------------------------------
  
  <1> The previous write index for the data stream.
  <2> The new write index for the data stream.
  <3> Whether the index was rolled over.
  <4> Whether the rollover was dry run.
  <5> The result of each condition.
  
  ////
  [source,console]
  -----------------------------------
  DELETE /_data_stream/my-data-stream
  -----------------------------------
  // TEST[continued]
  ////
  
  [[rollover-index-settings-ex]]
  ===== Specify settings for the target index
  
  The settings, mappings, and aliases for the new index are taken from any
  matching <<indices-templates,index templates>>. If the rollover target is an index
  alias, you can specify `settings`, `mappings`, and `aliases` in the body of the request
  just like the <<indices-create-index,create index>> API. Values specified in the request
  override any values set in matching index templates. For example, the following
  `rollover` request overrides the `index.number_of_shards` setting:
  
  