开发者

How to call solr to optimize using java code

开发者 https://www.devze.com 2023-01-16 13:55 出处:网络
Not under shell I开发者_运维百科 want to call the optimize using Java code and get notification when the optimize process is finished.Just fire a request to /solr/update?optimize=true from anywhere/a

Not under shell I开发者_运维百科 want to call the optimize using Java code and get notification when the optimize process is finished.


Just fire a request to /solr/update?optimize=true from anywhere/anything that has access to the Solr server, e.g:

curl 'http://localhost:8983/solr/update?optimize=true'


Using solrj, you call the optimize method of the class CommonsHttpSolrServer.

See this question about how to know when the optimize is done.


Can you be little more specific about your requirement,anyway Here is how i optimize the solr using solrj EmbeddedSolrServer,

SolrServer server = CacheServer.getCacheInstance().getServer();
    try {
        server.optimize();
    } catch (SolrServerException e) {

        e.printStackTrace();

    } catch (IOException e) {

        e.printStackTrace();

    }

For more details about optimize

0

精彩评论

暂无评论...
验证码 换一张
取 消