如何使用SolrJ运行完全导入命令

时间:2012-08-03 12:52:41

标签: java solr solrj

Plz建议,如何运行command = full-import?

 SolrServer solrServer = new HttpSolrServer("http://localhost:8080/solr");

那么......

谢谢!

2 个答案:

答案 0 :(得分:5)

请查看此wiki页面以及其中的拼写检查示例。它使用旧的CommonsHttpSolrServer,但它与您想要的类似。这段代码应该是您正在寻找的,即使我还没有尝试过:

SolrServer solrServer = new HttpSolrServer("http://localhost:8080/solr");
ModifiableSolrParams params = new ModifiableSolrParams();
params.set("qt", "/dataimport");
params.set("command", "full-import");
QueryResponse response = solrServer.query(params);

答案 1 :(得分:1)

在SolrJ 7中

import org.apache.solr.client.solrj.SolrClient; 
import org.apache.solr.client.solrj.SolrQuery; 
import org.apache.solr.client.solrj.SolrServerException; 
import org.apache.solr.client.solrj.impl.HttpSolrClient; 
import org.apache.solr.client.solrj.response.QueryResponse;

SolrClient client = new HttpSolrClient.Builder("http://localhost:8983/solr/test_core").build();

SolrQuery query = new SolrQuery(); 
query.set("qt", "/dataimport"); 
query.set("command", "full-import"); 

QueryResponse response = client.query(query);