On 8/8/2014 8:29 AM, Sören Schneider wrote: > Thanks for your helpful reply. Your code snippet works perfectly, but > I have another question. Do I have to manually move the index files in > the appropriate directories of the Solr cores, that should be swapped? > > Could you please post the content of your "updateDirectories()" method?
There's no need to manually move or copy index files. The swap method reassigns each core name to the other core's instanceDir/dataDir -- the files don't move and the directory doesn't change name, but Solr changes its idea of which core refers to which files. The updateDirectories method is purely for my object's housekeeping. It does not do anything to Solr itself: /** * Read dataDir and instanceDir from Solr and set the class variables. * * @throws BuildException * */ private void updateDirectories() throws BuildException { try { NamedList<Object> s = getCoreStatus(); _dataDir = s.get(SOLR_DATADIR).toString(); _instanceDir = s.get(SOLR_INSTANCEDIR).toString(); } catch (Exception e) { throw new BuildException("Unable to refresh " + _prefix + _name, e); } } SOLR_DATADIR is "dataDir" and SOLR_INSTANCEDIR is "instanceDir". This is getCoreStatus, used in updateDirectories: /** * Gets the status from CoreAdmin. * * @return NamedList<Object> * @throws BuildException */ final NamedList<Object> getCoreStatus() throws BuildException { CoreAdminRequest car = new CoreAdminRequest(); car.setCoreName(_name); car.setAction(CoreAdminAction.STATUS); NamedList<Object> nl; try { nl = car.process(_serverSolr).getCoreStatus(_name); } catch (Exception e) { throw new BuildException("Failed core status: " + _prefix + _name, e); } return nl; } Thanks, Shawn