optimize.asciidoc 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. [source,js]
  9. --------------------------------------------------
  10. $ curl -XPOST 'http://localhost:9200/twitter/_optimize'
  11. --------------------------------------------------
  12. [float]
  13. [[optimize-parameters]]
  14. === Request Parameters
  15. The optimize API accepts the following request parameters:
  16. [horizontal]
  17. `max_num_segments`:: The number of segments to optimize to. To fully
  18. optimize the index, set it to `1`. Defaults to simply checking if a
  19. merge needs to execute, and if so, executes it.
  20. `only_expunge_deletes`:: Should the optimize process only expunge segments with
  21. deletes in it. In Lucene, a document is not deleted from a segment, just marked
  22. as deleted. During a merge process of segments, a new segment is created that
  23. does not have those deletes. This flag allows to only merge segments that have
  24. deletes. Defaults to `false`. Note that this won't override the
  25. `index.merge.policy.expunge_deletes_allowed` threshold.
  26. `flush`:: Should a flush be performed after the optimize. Defaults to
  27. `true`.
  28. `wait_for_merge`:: Should the request wait for the merge to end. Defaults
  29. to `true`. Note, a merge can potentially be a very heavy operation, so
  30. it might make sense to run it set to `false`.
  31. `force`:: Force a merge operation, even if there is a single segment in the
  32. shard with no deletions.
  33. [float]
  34. [[optimize-multi-index]]
  35. === Multi Index
  36. The optimize API can be applied to more than one index with a single
  37. call, or even on `_all` the indices.
  38. [source,js]
  39. --------------------------------------------------
  40. $ curl -XPOST 'http://localhost:9200/kimchy,elasticsearch/_optimize'
  41. $ curl -XPOST 'http://localhost:9200/_optimize'
  42. --------------------------------------------------