0

I am trying to write a quick class to trigger the data import on solr. I know I can just use HttpClient, but I've already got Spring-Data-Solr configured and it has the server configured etc.

Is it possible to use the Query interface and the Solr Template to just send a request to dataimport request handler with "command=full-import" as params?

How can I do that?

Richard G
  • 5,243
  • 11
  • 53
  • 95

1 Answers1

0

If you have access to SolrTemplate instance, you could execute a SolrCallback as follows:

solrTemplate.execute(new SolrCallback<Void>() {
    @Override
    public Void doInSolr(SolrServer solrServer) throws SolrServerException, IOException {
        ModifiableSolrParams params = new ModifiableSolrParams();
        params.set("qt", "/dataimport");
        params.set("command", "full-import");
        solrServer.query(params);
        return null;
    }
});
Francisco Spaeth
  • 23,493
  • 7
  • 67
  • 106