Example usage for org.apache.solr.client.solrj SolrClient optimize

List of usage examples for org.apache.solr.client.solrj SolrClient optimize

Introduction

In this page you can find the example usage for org.apache.solr.client.solrj SolrClient optimize.

Prototype

public UpdateResponse optimize(boolean waitFlush, boolean waitSearcher, int maxSegments)
        throws SolrServerException, IOException 

Source Link

Document

Performs an explicit optimize, causing a merge of all segments to one.

Usage

From source file:net.yacy.cora.federate.solr.instance.ServerShard.java

License:Open Source License

/** 
 * Performs an explicit optimize, causing a merge of all segments to one.
 * <p>//from  ww  w  .j  a v a  2 s  .  c  o  m
 * Note: In most cases it is not required to do explicit optimize
 * @param waitFlush  block until index changes are flushed to disk
 * @param waitSearcher  block until a new searcher is opened and registered as the main query searcher, making the changes visible 
 * @param maxSegments  optimizes down to at most this number of segments
 * @throws IOException If there is a low-level I/O error.
 */
@Override
public UpdateResponse optimize(boolean waitFlush, boolean waitSearcher, int maxSegments)
        throws SolrServerException, IOException {
    if (!this.writeEnabled)
        return _dummyOKResponse;
    UpdateResponse ur = null;
    for (SolrClient s : this.shards)
        ur = s.optimize(waitFlush, waitSearcher, maxSegments);
    return ur;
}