optimize.asciidoc 2.0 KB

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