use of org.nextprot.api.tasks.solr.indexer.PublicationSolrindexer in project nextprot-api by calipho-sib.
the class GenerateSolrPublicationIndex method start.
@Override
public void start(String[] args) {
PublicationService publicationService = getBean(PublicationService.class);
int pubcnt = 0;
String solrServer = System.getProperty("solr.server");
NPreconditions.checkNotNull(solrServer, "Please set solr.server variable. For example: java -Dsolr.server=http://localhost:8983/solr/nppublications1");
logger.info("Solr server: " + solrServer);
SolrIndexer<Publication> indexer = new PublicationSolrindexer(solrServer, publicationService);
// Remove previous indexes
logger.info("removing all solr publication records");
indexer.clearDatabase("");
List<Long> allpubids;
logger.info("getting all publications from API");
long start = System.currentTimeMillis();
allpubids = publicationService.findAllPublicationIds();
logger.info("indexing " + allpubids.size() + " publications...");
for (Long id : allpubids) {
Publication currpub = publicationService.findPublicationById(id);
if (currpub.getPublicationType().equals(PublicationType.ARTICLE)) {
indexer.add(currpub);
pubcnt++;
}
if ((pubcnt % 5000) == 0)
logger.info(pubcnt + "/" + allpubids.size() + " publications done");
}
indexer.addRemaing();
logger.info("comitting");
indexer.commit();
logger.info(pubcnt + " publications indexed in " + (System.currentTimeMillis() - start) / 1000 + " seconds...END");
}
Aggregations