Added ability to perform Solr optimize on the search/discovery core. Can be run with ./dspace update-discovery-index -o

Issue #DS-615 - Ability to perform maintenance on SOLR with solr.optimize

git-svn-id: http://scm.dspace.org/svn/repo/dspace/trunk@5751 9c30dcfa-912a-0410-8fc2-9e0234be79fd
This commit is contained in:
Peter Dietz
2010-11-05 22:45:45 +00:00
parent 9d3a759dd3
commit 39b1d19f3b
4 changed files with 28 additions and 0 deletions

View File

@@ -109,6 +109,9 @@ public class IndexClient {
options.addOption(OptionBuilder.isRequired(false).withDescription(
"print this help message").create("h"));
options.addOption(OptionBuilder.isRequired(false).withDescription(
"optimize search solr core").create("o"));
try {
line = new PosixParser().parse(options, args);
} catch (Exception e) {
@@ -141,6 +144,9 @@ public class IndexClient {
} else if (line.hasOption("b")) {
log.info("(Re)building index from scratch.");
indexer.createIndex(context);
} else if (line.hasOption("o")) {
log.info("Optimizing search core.");
indexer.optimize();
} else {
log.info("Updating and Cleaning Index");
indexer.cleanIndex(line.hasOption("f"));

View File

@@ -80,4 +80,6 @@ public interface IndexingService {
void cleanIndex(boolean force) throws IOException,
SQLException, SearchServiceException;
void optimize();
}

View File

@@ -423,6 +423,25 @@ public class SolrServiceImpl implements SearchService, IndexingService {
}
/**
* Maintenance to keep a SOLR index efficient.
* Note: This might take a long time.
*/
public void optimize() {
try {
long start = System.currentTimeMillis();
System.out.println("SOLR Search Optimize -- Process Started:"+start);
getSolr().optimize();
long finish = System.currentTimeMillis();
System.out.println("SOLR Search Optimize -- Process Finished:"+finish);
System.out.println("SOLR Search Optimize -- Total time taken:"+(finish-start) + " (ms).");
} catch (SolrServerException sse) {
System.err.println(sse.getMessage());
} catch (IOException ioe) {
System.err.println(ioe.getMessage());
}
}
// //////////////////////////////////

View File

@@ -57,6 +57,7 @@
(Peter Dietz)
- [DS-192] Bitstreams should be returned ordered
- [DS-549] Added <a name> anchors in XMLUI
- [DS-615] Added ability to perform Solr optimize on the search/discovery core.
(Stuart Lewis, Christophe Dupriez)
- [DS-686] Incorrect use of UTF8 in DSpaceCSV