The force merge API allows to optimize one or more indexes for faster search by merging the number of Lucene segments (which grow over time). Read more on the official documentation.
There isn't really a whole lot to using this DSL. Simply specify a single index or a sequence of indexes.
client.execute {
forceMerge("index1")
}
or
client.execute {
forceMerge("index1", "index2", ....)
}
There are only a few options.
maxSegments
allows you to choose how many segments to merge to. To merge to a single segment for example, set this value to 1.
client.execute {
forceMerge("index1").maxSegments(1)
}
If onlyExpungeDeletes
is set to true, then only expunge segments containing document deletions.
client.execute {
forceMerge("index1").onlyExpungeDeletes(true)
}
If waitForCompletion
is set to false, then the future will complete as soon as the request has been received. Elasticsearch default is true
client.execute {
forceMerge("index1").waitForCompletion(true)
}