dsmiley commented on code in PR #2764:
URL: https://github.com/apache/solr/pull/2764#discussion_r1802088278


##########
solr/core/src/java/org/apache/solr/handler/designer/SchemaDesignerConfigSetHelper.java:
##########
@@ -533,11 +516,31 @@ List<SolrInputDocument> getStoredSampleDocs(final String 
configSet) throws IOExc
           collectionApiEndpoint(BLOB_STORE_ID, "blob", configSet + "_sample")
               .setParameter(CommonParams.WT, "filestream")
               .build();
+
     } catch (URISyntaxException e) {
       throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, e);
     }
+    final var params = new ModifiableSolrParams();
+    var request =
+        new GenericSolrRequest(SolrRequest.METHOD.GET, "/blob/" + configSet + 
"_sample", params);
+    request.setRequiresCollection(true);
+    request.setResponseParser(new InputStreamResponseParser("filestream"));

Review Comment:
   why set the response parser here?



##########
solr/core/src/java/org/apache/solr/handler/designer/SchemaDesignerConfigSetHelper.java:
##########
@@ -128,43 +127,27 @@ class SchemaDesignerConfigSetHelper implements 
SchemaDesignerConstants {
   Map<String, Object> analyzeField(String configSet, String fieldName, String 
fieldText)
       throws IOException {
     final String mutableId = getMutableId(configSet);
-    final URI uri;
-    try {
-      uri =
-          collectionApiEndpoint(mutableId, "analysis", "field")
-              .setParameter(CommonParams.WT, CommonParams.JSON)
-              .setParameter("analysis.showmatch", "true")
-              .setParameter("analysis.fieldname", fieldName)
-              .setParameter("analysis.fieldvalue", "POST")
-              .build();
-    } catch (URISyntaxException e) {
-      throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, e);
-    }
-
-    Map<String, Object> analysis = Collections.emptyMap();
-    HttpPost httpPost = new HttpPost(uri);
-    httpPost.setHeader("Content-Type", "text/plain");
-    httpPost.setEntity(new 
ByteArrayEntity(fieldText.getBytes(StandardCharsets.UTF_8)));
+    var solrParams = new ModifiableSolrParams();
+    solrParams.add("analysis.showmatch", "true");
+    solrParams.add("analysis.fieldname", fieldName);
+    solrParams.add("analysis.fieldvalue", "POST");
+    var request = new GenericSolrRequest(SolrRequest.METHOD.POST, 
"/analysis/field", solrParams);
+    request.withContent(fieldText.getBytes(StandardCharsets.UTF_8), 
"text/plain");
+    request.setRequiresCollection(true);
+    request.setResponseParser(new InputStreamResponseParser(null));

Review Comment:
   ```suggestion
       request.setResponseParser(new InputStreamResponseParser("json"));
   ```



##########
solr/core/src/java/org/apache/solr/handler/designer/SchemaDesignerConfigSetHelper.java:
##########
@@ -128,43 +127,27 @@ class SchemaDesignerConfigSetHelper implements 
SchemaDesignerConstants {
   Map<String, Object> analyzeField(String configSet, String fieldName, String 
fieldText)
       throws IOException {
     final String mutableId = getMutableId(configSet);
-    final URI uri;
-    try {
-      uri =
-          collectionApiEndpoint(mutableId, "analysis", "field")
-              .setParameter(CommonParams.WT, CommonParams.JSON)
-              .setParameter("analysis.showmatch", "true")
-              .setParameter("analysis.fieldname", fieldName)
-              .setParameter("analysis.fieldvalue", "POST")
-              .build();
-    } catch (URISyntaxException e) {
-      throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, e);
-    }
-
-    Map<String, Object> analysis = Collections.emptyMap();
-    HttpPost httpPost = new HttpPost(uri);
-    httpPost.setHeader("Content-Type", "text/plain");
-    httpPost.setEntity(new 
ByteArrayEntity(fieldText.getBytes(StandardCharsets.UTF_8)));
+    var solrParams = new ModifiableSolrParams();
+    solrParams.add("analysis.showmatch", "true");
+    solrParams.add("analysis.fieldname", fieldName);
+    solrParams.add("analysis.fieldvalue", "POST");
+    var request = new GenericSolrRequest(SolrRequest.METHOD.POST, 
"/analysis/field", solrParams);
+    request.withContent(fieldText.getBytes(StandardCharsets.UTF_8), 
"text/plain");
+    request.setRequiresCollection(true);
+    request.setResponseParser(new InputStreamResponseParser(null));

Review Comment:
   Actually, might `JsonMapResponseParser` better semantically represent what 
you want to do and maybe also cuts down on the lines of code needed?  How did 
you find InputStreamResponseParser anyway; that thing is very weird/awkward.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to