The wiki page, http://wiki.apache.org/solr/DataImportHandler explains how to index data using DataImportHandler. But the example uses a command to initiate the import operation. How can I schedule a job to do this on a regular basis?c
A:
On UNIX/Linux, cron jobs are your friends! On Windows, there is Task Scheduler.
UPDATE
To do it from Java code, since this is a simple GET request, you can use the HTTP Client library. See this tutorial on using the GetMethod.
If you need to programmatically send other requests to Solr, you probably should use the Solrj library. It allows to send all the basic commands to Solr ant it can be configured to access any Solr handlers:
CommonsHttpSolrServer server = new CommonsHttpSolrServer("http://localhost:8983/solr");
ModifiableSolrParams params = new ModifiableSolrParams();
params.set("command", "full-import");
QueryRequest request = new QueryRequest(params);
request.setPath("/dataimport");
server.request(request);
Pascal Dimassimo
2010-07-08 17:16:16
Thanks Pascal. My question was different. I need to fire the command http://<host>:<port>/solr/dataimport?command=full-import for the indexing operation. How can I do that using a java class? (as against typing in the command in a browser window?)
Eldo
2010-07-08 17:49:29
see my updates in the answer
Pascal Dimassimo
2010-07-08 23:59:45
Also, if you are doing it from cron, a wget http://127.0.0.1:8983/solr/dataimport?command=full-import works great!
Eric Pugh
2010-07-09 14:37:49