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() 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   w  w w .j a  v  a 2  s  .  c o  m*/
 * waitFlush=true and waitSearcher=true to be inline with the defaults for plain HTTP access
 * <p>
 * Note: In most cases it is not required to do explicit optimize
 * @throws IOException If there is a low-level I/O error.
 */
@Override
public UpdateResponse optimize() throws SolrServerException, IOException {
    if (!this.writeEnabled)
        return _dummyOKResponse;
    UpdateResponse ur = null;
    for (SolrClient s : this.shards)
        ur = s.optimize();
    return ur;
}

From source file:org.intermine.api.searchengine.solr.SolrIndexHandler.java

License:GNU General Public License

private void optimize(SolrClient solrClient) throws IOException {

    long startTime = System.currentTimeMillis();

    try {/*from   w ww .  ja  va 2 s. com*/
        solrClient.optimize();

        LOG.info("Optimizing Solr Index finished in " + (System.currentTimeMillis() - startTime) + "ms");

    } catch (SolrServerException e) {
        LOG.error("Error while optimizing", e);
        e.printStackTrace();
    }

}