Index: /gs3-extensions/solr/trunk/src/perllib/solrbuilder.pm
===================================================================
--- /gs3-extensions/solr/trunk/src/perllib/solrbuilder.pm	(revision 25888)
+++ /gs3-extensions/solr/trunk/src/perllib/solrbuilder.pm	(revision 25889)
@@ -116,4 +116,6 @@
 	my $core_prefix = (defined $site) ? "$site-$collect" : $collect;
 	my $core        = $core_prefix; # unused in this call to solr_passes
+
+	$core = "building-".$core unless $self->{'incremental'}; # core points to building only for force_removeold
 
         print STDERR "Executable:    $solr_passes_exe\n";
@@ -397,4 +399,7 @@
 	if ($force_removeold) {
 	    print $outhandle "\n-removeold set (new index will be created)\n";
+
+	    # create cores under temporary core names, corresponding to building directory
+	    $core = "building-".$core; 
 
 	    my $full_index_dir = &util::filename_cat($build_dir,$index_dir);
@@ -516,4 +521,6 @@
 	my $core        = "$core_prefix-$ds_idx";
 
+	$core = "building-".$core unless $self->{'incremental'}; # core points to building only for force_removeold
+
 	print STDERR "Cmd: $solr_passes_exe $core index \"$build_dir\" \"$indexdir\"   $osextra\n";
 	if (!open($handle, "| $solr_passes_exe $core index \"$build_dir\" \"$indexdir\"   $osextra")) {
Index: /gs3-extensions/solr/trunk/src/perllib/solrserver.pm
===================================================================
--- /gs3-extensions/solr/trunk/src/perllib/solrserver.pm	(revision 25888)
+++ /gs3-extensions/solr/trunk/src/perllib/solrserver.pm	(revision 25889)
@@ -276,7 +276,10 @@
 {
     my $self = shift @_;
-    my ($core) = @_;
+    my ($core, $delete) = @_;
 
     my $cgi_get_args = "action=UNLOAD&core=$core"; # &deleteIndex=true from Solr3.3
+    if(defined $delete && $delete == 1) {
+	$cgi_get_args = $cgi_get_args."&deleteIndex=true";
+    }
 
     $self->_admin_service($cgi_get_args);
Index: /main/trunk/greenstone2/bin/script/activate.pl
===================================================================
--- /main/trunk/greenstone2/bin/script/activate.pl	(revision 25888)
+++ /main/trunk/greenstone2/bin/script/activate.pl	(revision 25889)
@@ -601,14 +601,15 @@
 	
 	if($removeold) {
-
-	    if ($buildtype eq "solr") {
-		# if solr, remove any cores using the index_dir before deleting this dir
-		foreach my $corename (@corenames) {
-		    $solr_server->admin_unload_core($corename);
-		}
-	    }	
 	    
 		if(&util::dir_exists($index_dir)) {
 			&print_task_msg("Removing \"index\"");
+
+			if ($buildtype eq "solr") {
+			    # if solr, remove any cores that are using the index_dir before deleting this dir
+			    foreach my $corename (@corenames) {
+				$solr_server->admin_unload_core($corename);
+			    }
+			}	
+
 			&util::rm_r($index_dir);
 			
@@ -624,4 +625,11 @@
 		# the collection at this point since activate.pl lives on the server side
 		
+		if ($buildtype eq "solr") {
+		    # if solr, remove any cores that are using the building_dir before moving this dir onto index
+		    foreach my $corename (@corenames) {
+			$solr_server->admin_unload_core("building-$corename");
+		    }
+		}
+
 		# Move the building directory to become the new index directory
 		&print_task_msg("Moving \"building\" -> \"index\"");
@@ -632,8 +640,8 @@
 	}
 	elsif ($keepold) {
-	    	if ($buildtype eq "solr") { 
-		    # if solr, remove any cores using the index_dir before deleting this dir
+	    	if ($buildtype eq "solr") { ### no building- prefix for keepold incremental case?
+		    # if solr, remove any cores that may be using the building_dir before moving this dir onto index
 		    foreach my $corename (@corenames) {			
-			$solr_server->admin_unload_core($corename);
+			$solr_server->admin_unload_core("building-$corename") if $solr_server->admin_ping_core("building-$corename");
 		    }
 		}
@@ -646,7 +654,12 @@
 	
     if ($buildtype eq "solr") {
-	# Call CREATE action to get the old cores pointing to the index folder
+	# Call CREATE action to get all cores pointing to the index folder, since building is now index
+	### Should already be using the index_dir directory for $keepold (incremental) case? Then call RELOAD CORE
 	foreach my $corename (@corenames) {
-	    $solr_server->admin_create_core($corename, $index_dir);
+	    if($removeold) {
+		$solr_server->admin_create_core($corename, $index_dir);
+	    } elsif ($keepold) {
+		$solr_server->admin_reload_core($corename); 
+	    }
 	}
 
