我可以使用以下代码重新索引整个solr核心:
public void indexSolr() throws SolrServerException, IOException {
HttpSolrServer solr = new HttpSolrServer(solrIndexPath);
logger.info("Indexing fcv solr at " + solrIndexPath);
// reindex to pickup new articles
ModifiableSolrParams params = new ModifiableSolrParams();
params.set("qt", "/" + solrDataImportPath);
params.set("command", "full-import");
params.set("clean", "true");
params.set("commit", "true");
solr.query(params);
}
如何仅将一个文档插入索引而不必对整个对象进行索引?
解决方法:
您是否正在寻找这样的东西?
public void insertOneDoc() throws SolrServerException, IOException {
HttpSolrServer solr = new HttpSolrServer(solrIndexPath);
SolrInputDocument doc = new SolrInputDocument();
doc.addField("fieldName", "fieldValue");
solr.add(doc);
solr.commit();
}
因为那样会将单个文档添加到HttpSolrServer引用的索引中.