Group group = gbuilder.withName("Options").withOption(wikipediaFileOpt).withOption(numDocsOpt).withOption(solrURLOpt).withOption(solrBatchOpt).create();
Parser parser = new Parser();
parser.setGroup(group);
CommandLine cmdLine = parser.parse(args);
File file;
file = new File(cmdLine.getValue(wikipediaFileOpt).toString());
File[] dumpFiles;
if (file.isDirectory()) {
dumpFiles = file.listFiles(new FilenameFilter() {
public boolean accept(File file, String s) {
return s.endsWith(".xml");
}
});
} else {
dumpFiles = new File[]{file};
}
int numDocs = Integer.MAX_VALUE;
if (cmdLine.hasOption(numDocsOpt)) {
numDocs = Integer.parseInt(cmdLine.getValue(numDocsOpt).toString());
}
String url = DEFAULT_SOLR_URL;
if (cmdLine.hasOption(solrURLOpt)) {
url = cmdLine.getValue(solrURLOpt).toString();
}
int batch = 100;
if (cmdLine.hasOption(solrBatchOpt)) {
batch = Integer.parseInt(cmdLine.getValue(solrBatchOpt).toString());
}
WikipediaIndexer indexer = new WikipediaIndexer(new CommonsHttpSolrServer(url));
int total = 0;
for (int i = 0; i < dumpFiles.length && total < numDocs; i++) {
File dumpFile = dumpFiles[i];