Elasticsearch 7.0 Cookbook(Fourth Edition)
上QQ阅读APP看书,第一时间看更新

How to do it...

The HTTP method that's used is POST. The URL format for optimizing one or more indices is as follows:

http://<server>/<index_name(s)>/_flush[?refresh=True]

The URL format for optimizing all the indices in a cluster is:

http://<server>/_flush[?refresh=True]

For optimizing, or to ForceMerge an index, we will perform the following steps:

  1. If we consider the index we created in the Creating an index recipe, the call will be as follows:
POST /myindex/_forcemerge
  1. The result returned by Elasticsearch should be as follows:
{
"_shards" : {
"total" : 2,
"successful" : 1,
"failed" : 0
}
}

The result contains the shard operation status.