return "solrconfig-duh-optimize.xml";
}
public void testOptimize() throws Exception {
SolrCore core = h.getCore();
UpdateHandler updater = core.getUpdateHandler();
AddUpdateCommand cmd = new AddUpdateCommand();
cmd.overwriteCommitted = true;
cmd.overwritePending = true;
cmd.allowDups = false;
//add just under the merge factor, so no segments are merged
//the merge factor is 100 and the maxBufferedDocs is 2, so there should be 50 segments
for (int i = 0; i < 99; i++) {
// Add a valid document
cmd.doc = new Document();
cmd.doc.add(new Field("id", "id_" + i, Field.Store.YES, Field.Index.NOT_ANALYZED));
cmd.doc.add(new Field("subject", "subject_" + i, Field.Store.NO, Field.Index.ANALYZED));
updater.addDoc(cmd);
}
CommitUpdateCommand cmtCmd = new CommitUpdateCommand(false);
updater.commit(cmtCmd);
updater.commit(cmtCmd); // commit twice to give systems such as windows a chance to delete the old files
String indexDir = core.getIndexDir();
assertNumSegments(indexDir, 50);
//now do an optimize
cmtCmd = new CommitUpdateCommand(true);
cmtCmd.maxOptimizeSegments = 25;