我想从我的java代码修改solrconfig.xml文件。如果有任何资源提供了在SolrJ中实现抽象SolrRequest以修改solrconfig.xml的示例,您能给我指出他们吗?
谢谢
发布于 2018-04-05 21:44:05
您不能直接从该接口修改solrconfig.xml,但您可以通过use the Config API修改配置,而无需编辑solrconfig.xml。
Config API创建了一个在solrconfig中定义的设置之上使用的"overlay“,并允许您操作配置文件中包含的大多数方面。
您可以看到如何使用manually build JSON and set it with SolrJ。我不确定是否有什么东西添加到SolrJ中以将其抽象出来,但问题跟踪器上的开放票证表明它还没有发生。这还取决于您使用的SolrJ版本。
发布于 2019-07-29 20:56:28
正如@MatsLindh所说,你可以使用 Config API来更新solr配置。您也不需要重新加载集合。
您可以找到配置接口here的命令属性
以下是较新版本的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命令here
https://stackoverflow.com/questions/49673420
复制相似问题