有没有办法强制 Solr 每 X 分钟读取一次索引?

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

我正在尝试使用 Solr 来读取和搜索另一个应用程序提供的索引。这些索引每 15 分钟复制到 NAS。

有没有办法强制 Solr 每 15 分钟重新读取一次索引?有没有一种方法可以使用 CRON 表达式将搜索器设置为过期或重新加载?

我知道我可以重新加载核心...但我想问是否还有其他方法...

谢谢。

如果您能够编写一些 CRON 表达式,则可以通过这种方式完成:

Solr 有一个用于重新加载核心的端点,因此您只需每 X 分钟访问一次此 URI。

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

是的,您可以使用 CRON 表达式。

DataImportHandler 将允许您根据您的 NAS 索引更新您的 Solr 索引。 查找 "delta-import" 命令 "for incremental imports and change detection":

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

以编程方式使用像 SolrJ 这样的 Client API

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);