I've got Solr set up now with two cores which I call live and rebuild and
which point to core0 and core1 directories respectively.  My solr.xml file
contains:

  <cores adminPath="/admin/cores"
    maxCores="4"
    shareSchema="true"
        shareConfig="true">
    <core name="live" instanceDir="core0" />
    <core name="rebuild" instanceDir="core1" />
  </cores>

In my Spring MVC application I have Solr set up as an embedded server and
have two singleton beans which I use to refer to the live server and the
rebuild server.  That all seems to work fine. I have a Java rebuild method
which I use to load up the rebuild core with data.  At the end of this
method I am attempting to switch the cores around so that the main
application can still keep using the live core and automatically pick up the
new data.  Unfortunately, it doesn't appear to be swapping, or rather it
does sometimes but I can't see why.

My swapping code is:

            // Swap the cores
            CoreAdminRequest car = new CoreAdminRequest();
            car.setCoreName("live");
            car.setOtherCoreName("rebuild");
            car.setAction(CoreAdminParams.CoreAdminAction.SWAP);
            car.process(solrServer);
            solrServer.commit();

The solrServer variable would be pointing to my rebuild core that I have
just updated. I see that index files in core1 get updated.  And I've also
see that the index files in core0 have been updated at some time earlier in
the day due to timestamps.

I haven't been able to see a working example of swapping cores via Java so I
wondered whether I was doing it wrong or missing out an important step, or
perhaps I've got completely the wrong end of the stick and looking at the
timestamps on my files is not correct.  Regardless of this what I can see in
my application though is that searches that constantly look to the live core
return the same data so the swapping doesn't seem to take place.

Thanks in advance for any tips.
Shaun

Reply via email to