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

问题描述 投票:3回答:2

Plz建议,我怎么能运行command = full-import?

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

那么......

谢谢!

java solr solrj
2个回答
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
投票

在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);
© www.soinside.com 2019 - 2024. All rights reserved.