MCPcopy Create free account
hub / github.com/apache/solr / callGet

Method callGet

solr/core/src/java/org/apache/solr/cli/ApiTool.java:73–99  ·  view source on GitHub ↗
(String url, String credentials)

Source from the content-addressed store, hash-verified

71 }
72
73 protected String callGet(String url, String credentials) throws Exception {
74 URI uri = new URI(url.replace("+", "%20"));
75 String solrUrl = getSolrUrlFromUri(uri);
76 String path = uri.getPath();
77 try (var solrClient = CLIUtils.getSolrClient(solrUrl, credentials)) {
78 // For path parameter we need the path without the root so from the second / char
79 // (because root can be configured)
80 // E.g. URL is http://localhost:8983/solr/admin/info/system path is
81 // /solr/admin/info/system and the path without root is /admin/info/system
82 var req =
83 new GenericSolrRequest(
84 SolrRequest.METHOD.GET,
85 path.substring(path.indexOf("/", path.indexOf("/") + 1)),
86 getSolrParamsFromUri(uri) // .add("indent", "true")
87 );
88 // Using the "smart" solr parsers won't work, because they decode into Solr objects.
89 // When trying to re-write into JSON, the JSONWriter doesn't have the right info to print it
90 // correctly.
91 // All we want to do is pass the JSON response to the user, so do that.
92 req.setResponseParser(new JsonMapResponseParser());
93 NamedList<Object> response = solrClient.request(req);
94 // pretty-print the response to stdout
95 CharArr arr = new CharArr();
96 new JSONWriter(arr, 2).write(response.asMap(10));
97 return arr.toString();
98 }
99 }
100
101 /**
102 * Get Solr base url with port if present and root from URI

Callers 3

testQueryResponseMethod · 0.95
runImplMethod · 0.95

Calls 12

getSolrUrlFromUriMethod · 0.95
getSolrClientMethod · 0.95
getSolrParamsFromUriMethod · 0.95
toStringMethod · 0.95
getPathMethod · 0.65
writeMethod · 0.65
replaceMethod · 0.45
substringMethod · 0.45
indexOfMethod · 0.45
setResponseParserMethod · 0.45
requestMethod · 0.45
asMapMethod · 0.45

Tested by 2

testQueryResponseMethod · 0.76