Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,10 @@ private String getDefaultPath() {
private void handleGET() {
if (parts.size() == 1) {
// this is the whole config. sent out the whole payload
// v1 keeps internal section names (e.g. searchComponent); plurals are v2 only
V2ApiUtils.squashIntoSolrResponseWithoutHeader(
resp, new GetConfig(req).getConfig(req.getParams().getBool("expandParams", false)));
resp,
new GetConfig(req).getConfig(req.getParams().getBool("expandParams", false), false));
} else {
if (ConfigOverlay.NAME.equals(parts.get(1))) {
V2ApiUtils.squashIntoSolrResponseWithoutHeader(resp, new GetConfig(req).getOverlay());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,20 @@ public GetConfig(SolrQueryRequest solrQueryRequest) {
@Override
@PermissionName(CONFIG_READ_PERM)
public ConfigInfoResponse getConfig(boolean expandParams) {
return getConfig(expandParams, true);
}

public ConfigInfoResponse getConfig(boolean expandParams, boolean useExternalComponentNames) {
final var response = instantiateJerseyResponse(ConfigInfoResponse.class);
response.config = buildConfigMap(solrQueryRequest, expandParams);
Map<String, Object> configMap = buildConfigMap(solrQueryRequest, expandParams);
if (useExternalComponentNames) {
Map<String, Object> reMappedConfigMap = new NullKeyTolerantMap("children");
for (Map.Entry<String, Object> e : configMap.entrySet()) {
reMappedConfigMap.put(toExternalComponentName(e.getKey()), e.getValue());
}
configMap = reMappedConfigMap;
}
response.config = configMap;
return response;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,11 @@ public static void runConfigCommandExpectFailure(
}

public static void reqhandlertests(RestTestHarness writeHarness) throws Exception {
// The full "/config" response pluralizes searchComponent -> searchComponents under the V2
// API (see GetConfig#getConfig), but not under V1; the per-component endpoints used elsewhere
// in this test are unaffected since they already use the pluralized name.
String searchComponentKey =
writeHarness.getBaseURL().contains("/____v2/") ? "searchComponents" : "searchComponent";
String payload =
"{\n"
+ "'create-requesthandler' : { 'name' : '/x', 'class': 'org.apache.solr.handler.DumpRequestHandler' , 'startup' : 'lazy'}\n"
Expand Down Expand Up @@ -332,7 +337,7 @@ public static void reqhandlertests(RestTestHarness writeHarness) throws Exceptio
testForResponseElement(
writeHarness,
"/config",
asList("config", "searchComponent", "tc", "class"),
asList("config", searchComponentKey, "tc", "class"),
"org.apache.solr.handler.component.TermsComponent",
TIMEOUT_S);
payload =
Expand All @@ -343,14 +348,14 @@ public static void reqhandlertests(RestTestHarness writeHarness) throws Exceptio
testForResponseElement(
writeHarness,
"/config",
asList("config", "searchComponent", "tc", "class"),
asList("config", searchComponentKey, "tc", "class"),
"org.apache.solr.handler.component.TermVectorComponent",
TIMEOUT_S);

payload = "{\n" + "'delete-searchcomponent' : 'tc'" + "}";
runConfigCommand(writeHarness, "/config", payload);
testForResponseElement(
writeHarness, "/config", asList("config", "searchComponent", "tc"), null, TIMEOUT_S);
writeHarness, "/config", asList("config", searchComponentKey, "tc"), null, TIMEOUT_S);
// <valueSourceParser name="countUsage"
// class="org.apache.solr.core.CountUsageValueSourceParser"/>
payload =
Expand Down Expand Up @@ -444,7 +449,7 @@ public static void reqhandlertests(RestTestHarness writeHarness) throws Exceptio
testForResponseElement(
writeHarness,
"/config",
asList("config", "searchComponent", "myspellcheck", "spellchecker", "class"),
asList("config", searchComponentKey, "myspellcheck", "spellchecker", "class"),
"solr.DirectSolrSpellChecker",
TIMEOUT_S);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ public void testGetConfigFromCore() throws Exception {
assertTrue(response.config.containsKey("updateHandler"));
assertTrue(response.config.containsKey("query"));
assertTrue(response.config.containsKey("requestHandler"));
assertTrue(response.config.containsKey("searchComponent"));

assertFalse(response.config.containsKey("searchComponent"));
assertTrue(response.config.containsKey("searchComponents"));

assertTrue(response.config.containsKey("updateProcessor"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ V2 API::
http://localhost:8983/api/collections/techproducts/config
----

The response is the same merged configuration as the V1 API, with one difference: a plugin's unnamed child elements are grouped under a self-describing `children` key instead of an empty string, since Solr's V2 JSON serialization library does not allow empty-string keys:
The response is the same merged configuration as the V1 API, with two differences.

First, a plugin's unnamed child elements are grouped under a self-describing `children` key instead of an empty string, since Solr's V2 JSON serialization library does not allow empty-string keys:

[source,json]
----
Expand All @@ -87,6 +89,8 @@ The response is the same merged configuration as the V1 API, with one difference
]
}]
----

Second, the `searchComponent` and `queryResponseWriter` sections are renamed to their pluralized forms, `searchComponents` and `queryResponseWriters`, as described below.
====
======

Expand Down
Loading