How to reload the Solr core using SolrJ?
Question
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...
Solution
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();
OTHER TIPS
SolrJ contains a static convenience method for that in CoreAdminRequest
class:
reloadCore("<YOUR_CORE_NAME>", solrClient)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow