0

我想从我的 java 代码中修改 solrconfig.xml 文件。如果有任何来源提供了在 SolrJ 中实现抽象 SolrRequest 以修改 solrconfig.xml 的示例,请您指出我的意思。

谢谢

4

2 回答 2

1

您无法solrconfig.xml直接从 API 进行修改,但您可以使用 Config API来修改配置,而无需编辑solrconfig.xml.

Config API 创建一个“覆盖”,用于在 solrconfig 中定义的设置之上,并允许您操作包含在配置文件中的大多数方面。

您可以了解如何手动构建 JSON 并使用 SolrJ 进行设置。我不确定 SolrJ 中是否添加了任何内容以将其抽象出来,但问题跟踪器上的公开票证表明它尚未发生。它还取决于您使用的 SolrJ 版本。

于 2018-04-05T13:44:04.830 回答
0

正如@MatsLindh 所说,您可以使用Config API来更新 solr 配置。您也不需要重新加载集合。

您可以在此处找到配置 API 的命令属性

下面是更新属性 Solr (>7.0) 的代码updateHandler.autoSoftCommit.maxTime

//setting softCommit maxTime to 15000
final String command = "{\"set-property\":{\"updateHandler.autoSoftCommit.maxTime\":15000}}";

//path and method of request
final GenericSolrRequest rq = new GenericSolrRequest(SolrRequest.METHOD.POST, "/config", null);

// request string and request type
final ContentWriter content = new StringPayloadContentWriter(command, "application/json");

rq.setContentWriter(content);

//create your solrClient using zookeeper connection string
rq.process(solrClient, "<your collection name>");

您可以在此处找到等效的 curl 命令

于 2019-07-29T12:56:27.633 回答