简体   繁体   中英

How to reload the Solr core using SolrJ?

I am using SolrJ for indexing my data. I am updating the Synonym.txt file dynamically but Solr server is not getting the latest changes from Synonym.txt file, my previous question is how to update synonym.txt file dynamically? So I have to reload/restart the Solr core programatically... so how can I do that...?

thanks in advance...

The following code should be what you're looking for:

CoreAdminRequest adminRequest = new CoreAdminRequest();
adminRequest.setAction(CoreAdminAction.RELOAD);
CoreAdminResponse adminResponse = adminRequest.process(new HttpSolrServer(solrUrl));
NamedList<NamedList<Object>> coreStatus = adminResponse.getCoreStatus();

SolrJ在CoreAdminRequest类中包含一个静态便利方法:

reloadCore("<YOUR_CORE_NAME>", solrClient)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM