The following sample program will work with the Hadoop Version 0.20:
SolrConfig solrConfig = new SolrConfig(); Configuration conf = getJobConfiguration(); FileSystem fs = FileSystem.get(conf); if (fs.exists(outputPath)) fs.delete(outputPath, true); if (fs.exists(indexPath)) fs.delete(indexPath, true); for (int noShards = 0; noShards < noOfServer; noShards++) { //Set initial parameters IndexUpdateConfiguration iconf = new IndexUpdateConfiguration(conf); iconf.setIndexInputFormatClass(SolrXMLDocInputFormat.class); iconf.setLocalAnalysisClass(SolrLocalAnalysis.class); //configure the indexing for SOlr SolrIndexConfig solrIndexConf = solrConfig.mainIndexConfig; if (solrIndexConf.maxFieldLength != -1) iconf.setIndexMaxFieldLength(solrIndexConf.maxFieldLength); iconf.setIndexUseCompoundFile(solrIndexConf.useCompoundFile); iconf.setIndexMaxNumSegments(maxSegments); //initialize array Shard[] shards = new Shard[numShards]; for (int j = 0; j < shards.length; j++) { Path path = new Path(indexPath, NUMBER_FORMAT.format(j)); shards[j] = new Shard(versionNumber, path.toString(), generation); } //An implementation of an index updater interface which creates a Map/Reduce job configuration and run the //Map/Reduce job to analyze documents and update Lucene instances in parallel. IIndexUpdater updater = new SolrIndexUpdater(); updater.run(conf, new Path[] { inputPath }, outputPath, numMapTasks, shards);