dwarszawski
dwarszawski

Reputation: 23

Using Solr V2 API to update Solr config in standalone mode throws SolrException "Solr not running in cloud mode"

Trying to modify config with V2 API in Solr runnning in the standalone mode.

The request is build as follow:

V2Request v2Request = new V2Request.Builder(String.format("/collections/%s/config", collectionName))
                                                    .withMethod(SolrRequest.METHOD.POST)
                                                    .withPayload(actionPayLoad)
                                                    .build();

That results in the SolrException: "Solr not running in cloud mode "

It appears that V2 Http request is generated through org.apache.solr.apiV2HttpCall(Maven: org.apache.solr:solr-core:7.0.0) which requires to run Zookeeper

  protected DocCollection getDocCollection(String collectionName) {
    if (!cores.isZooKeeperAware()) {
      throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Solr not running in cloud mode ");
    }

Is there any equivalent Config API call for Solr running in standalone mode so without Zookeeper?

just noticed from https://lucene.apache.org/solr/guide/7_0/config-api.html that it should work in the similiar fashion:

The Config API enables manipulating various aspects of your solrconfig.xml using REST-like API > calls. This feature is enabled by default and works similarly in both SolrCloud and standalone mode. > Many commonly edited properties (such as cache sizes and commit settings) and request handler > definitions can be changed with this API.

Upvotes: 0

Views: 659

Answers (1)

dwarszawski
dwarszawski

Reputation: 23

here is solution to update solr config through V1 API:

Collection<ContentStream> contentStreams = ClientUtils.toContentStreams(actionPayLoad, "application/json; charset=UTF-8");
                GenericSolrRequest request = new GenericSolrRequest(SolrRequest.METHOD.POST, String.format("/%s/config", collectionName), null);
                request.setContentStreams(contentStreams);
                request.setUseV2(false);

Upvotes: 0

Related Questions