How to run optimize query query using Java API?

(Sumit Gupta) #1


I want to run optimize query on indexes using Java Api.
Please suggest me how can i achieve this.

Sumit Gupta

(finominfo) #2

The Optimize API
The Optimize API invokes the segments merge process on the given
indices. Just like
the RESTful version of this API, we are allowed to set the target number
of segments
or only remove the deleted documents from the index. For example, the
code snippet executes the optimize operation on the library index,
specifies that
the maximum number of segments is 2. The flush should be performed after the
operation and we are not only interested in removing the deleted documents:
OptimizeResponse response = client.admin().indices()

(system) #3