use of org.nextprot.api.tasks.solr.indexer.CvTermSolrIndexer in project nextprot-api by calipho-sib.
the class GenerateSolrTerminologyIndex method start.
@Override
public void start(String[] args) {
TerminologyService terminologyService = getBean(TerminologyService.class);
int termcnt = 0;
String solrServer = System.getProperty("solr.server");
NPreconditions.checkNotNull(solrServer, "Please set solr.server variable. For example: java -Dsolr.server=\"http://localhost:8983/solr/npcvs1\"");
logger.info("Solr server: " + solrServer);
// eg: java -Dsolr.ontology="UniprotFamilyCv" (don't forget CamelCasing)
String ontologyToReindex = System.getProperty("solr.ontology");
SolrIndexer<CvTerm> indexer = new CvTermSolrIndexer(solrServer);
List<CvTerm> allterms;
if (ontologyToReindex == null) {
// No arg: index all ontologies
System.err.println("indexing: all ontologies");
logger.info("indexing all terminologies");
indexer.clearDatabase("");
allterms = terminologyService.findAllCVTerms();
} else {
// Index ontology given as VM argument
System.err.println("indexing: " + ontologyToReindex);
logger.info("indexing terminology: " + ontologyToReindex);
indexer.clearDatabase("filters:" + ontologyToReindex);
allterms = terminologyService.findCvTermsByOntology(ontologyToReindex);
}
for (CvTerm term : allterms) {
indexer.add(term);
termcnt++;
if ((termcnt % 3000) == 0)
logger.info(termcnt + "/" + allterms.size() + " cv terms done");
}
indexer.addRemaing();
logger.info("comitting");
indexer.commit();
logger.info(termcnt + " terms indexed...END");
}
Aggregations