optimize.asciidoc 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. [[indices-optimize]]
  2. == Optimize
  3. The optimize API allows to optimize one or more indices through an API.
  4. The optimize process basically optimizes the index for faster search
  5. operations (and relates to the number of segments a Lucene index holds
  6. within each shard). The optimize operation allows to reduce the number
  7. of segments by merging them.
  8. This call will block until the optimize is complete. If the http connection
  9. is lost, the request will continue in the background, and
  10. any new requests will block until the previous optimize is complete.
  11. [source,js]
  12. --------------------------------------------------
  13. $ curl -XPOST 'http://localhost:9200/twitter/_optimize'
  14. --------------------------------------------------
  15. [float]
  16. [[optimize-parameters]]
  17. === Request Parameters
  18. The optimize API accepts the following request parameters:
  19. [horizontal]
  20. `max_num_segments`:: The number of segments to optimize to. To fully
  21. optimize the index, set it to `1`. Defaults to simply checking if a
  22. merge needs to execute, and if so, executes it.
  23. `only_expunge_deletes`:: Should the optimize process only expunge segments with
  24. deletes in it. In Lucene, a document is not deleted from a segment, just marked
  25. as deleted. During a merge process of segments, a new segment is created that
  26. does not have those deletes. This flag allows to only merge segments that have
  27. deletes. Defaults to `false`. Note that this won't override the
  28. `index.merge.policy.expunge_deletes_allowed` threshold.
  29. `flush`:: Should a flush be performed after the optimize. Defaults to
  30. `true`.
  31. [float]
  32. [[optimize-multi-index]]
  33. === Multi Index
  34. The optimize API can be applied to more than one index with a single
  35. call, or even on `_all` the indices.
  36. [source,js]
  37. --------------------------------------------------
  38. $ curl -XPOST 'http://localhost:9200/kimchy,elasticsearch/_optimize'
  39. $ curl -XPOST 'http://localhost:9200/_optimize'
  40. --------------------------------------------------