Search code examples
apachesearchsolrsolrjsynonym

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...


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();