Balpo
Balpo

Reputation: 13

Programatic Full Import in Solr using Java

I need to do a full-import with Java to a solr server.

I am trying it this way:

SolrServer srv = new CommonsHttpSolrServer(Settings.getInstance().getSolrURL());
SolrParams s = new SolrQuery("data?command=full-import");
srv.request(new QueryRequest(s));

but it does not work. The query executed is

params={q=data?command%3Dfull-import&wt=javabin&version=1} hits=0 status=0 QTime=1

So it is actually seeking "data?command=full-import".

Do you know a way to do it programmaticaly in Java?

Thank you

Upvotes: 1

Views: 1645

Answers (1)

Joel Westberg
Joel Westberg

Reputation: 2736

You need to use the ModifiableSolrParams object to accomplish this.

SolrServer solr = new CommonsHttpSolrServer("http://localhost:8983/solr");

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

QueryResponse response = solr.query(params);

Upvotes: 1

Related Questions