| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 | [[indices-optimize]]== OptimizeThe optimize API allows to optimize one or more indices through an API.The optimize process basically optimizes the index for faster searchoperations (and relates to the number of segments a Lucene index holdswithin each shard). The optimize operation allows to reduce the numberof segments by merging them.This call will block until the optimize is complete. If the http connectionis lost, the request will continue in the background, andany new requests will block until the previous optimize is complete.[source,js]--------------------------------------------------$ curl -XPOST 'http://localhost:9200/twitter/_optimize'--------------------------------------------------[float][[optimize-parameters]]=== Request ParametersThe optimize API accepts the following request parameters:[horizontal]`max_num_segments`:: The number of segments to optimize to. To fullyoptimize the index, set it to `1`. Defaults to simply checking if amerge needs to execute, and if so, executes it.`only_expunge_deletes`:: Should the optimize process only expunge segments withdeletes in it. In Lucene, a document is not deleted from a segment, just markedas deleted. During a merge process of segments, a new segment is created thatdoes not have those deletes. This flag allows to only merge segments that havedeletes. Defaults to `false`.  Note that this won't override the`index.merge.policy.expunge_deletes_allowed` threshold.`flush`::  Should a flush be performed after the optimize. Defaults to`true`.[float][[optimize-multi-index]]=== Multi IndexThe optimize API can be applied to more than one index with a singlecall, or even on `_all` the indices.[source,js]--------------------------------------------------$ curl -XPOST 'http://localhost:9200/kimchy,elasticsearch/_optimize'$ curl -XPOST 'http://localhost:9200/_optimize'--------------------------------------------------
 |