Grebenisan Mihai
Grebenisan Mihai

Reputation: 38

Is there a way to force Solr to read the indexes every X minutes?

I am trying to use Solr to read and search trough the indexes provided by an another application. These indexes are copied to a NAS every 15 minutes.

Is there a way to force Solr to re-read the indexes every 15 minutes ? Is there a way to set a searcher to expire or to be reloaded using maybe a CRON expression?

I am aware that I can reload the core... but I'm asking if maybe is there an another way...

Thanks.

Upvotes: 0

Views: 170

Answers (2)

c-val
c-val

Reputation: 191

Yes you can use a CRON expression.

DataImportHandler will allow you to update your Solr index based on your NAS-indexes. Look for the "delta-import" command "for incremental imports and change detection":

 http://<host>:<port>/solr/<collection_name>/dataimport?command=delta-import

Programmatically using a Client API like SolrJ:

CommonsHttpSolrServer server = new CommonsHttpSolrServer("http://localhost:8983/solr/<collection_name>");
ModifiableSolrParams params = new ModifiableSolrParams();
params.set("command", "delta-import");
QueryRequest request = new QueryRequest(params);
request.setPath("/dataimport");
server.request(request);

Upvotes: 2

Mysterion
Mysterion

Reputation: 9320

If you are able to write some CRON expression it could be done in that way:

Solr have an endpoint for reloading a core, so all you need is to hit this URI every X minutes.

Load a new core from the same configuration as an existing registered core. While the "new" core is initalizing, the "old" one will continue to accept requests. Once it has finished, all new request will go to the "new" core, and the "old" core will be unloaded.

http://localhost:8983/solr/admin/cores?action=RELOAD&core=core0

Upvotes: 2

Related Questions