如何在 Solr 中安排数据导入 [英] How can I Schedule data imports in Solr

查看:20
本文介绍了如何在 Solr 中安排数据导入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

维基页面,http://wiki.apache.org/solr/DataImportHandler 解释如何使用 DataImportHandler 索引数据.但是该示例使用命令来启动导入操作.我如何安排工作定期执行此操作?c

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

推荐答案

在 UNIX/Linux 上,cron 作业 是你的朋友!在 Windows 上,有 Task Scheduler.

On UNIX/Linux, cron jobs are your friends! On Windows, there is Task Scheduler.

更新
要从 Java 代码执行此操作,因为这是一个简单的 GET 请求,您可以使用 HTTP Client 图书馆.有关使用 GetMethod 的信息,请参阅本教程.

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.

如果您需要以编程方式向 Solr 发送其他请求,您可能应该使用 Solrj 库.它允许将所有基本命令发送到 Solr ant 它可以配置为访问任何 Solr 处理程序:

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

这篇关于如何在 Solr 中安排数据导入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆