gerlowskija commented on code in PR #1649:
URL: https://github.com/apache/solr/pull/1649#discussion_r1210157336


##########
solr/core/src/java/org/apache/solr/handler/admin/api/SchemaSimilarityAPI.java:
##########
@@ -31,18 +38,30 @@
  * <p>This API (GET /v2/collections/collectionName/schema/similarity) is 
analogous to the v1
  * /solr/collectionName/schema/similarity API.
  */
-public class SchemaSimilarityAPI {
-  private final SchemaHandler schemaHandler;
+public class SchemaSimilarityAPI extends JerseyResource {
 
-  public SchemaSimilarityAPI(SchemaHandler schemaHandler) {
-    this.schemaHandler = schemaHandler;
+  private SolrCore solrCore;
+
+  @Inject
+  public SchemaSimilarityAPI(SolrCore solrCore) {
+    this.solrCore = solrCore;
+  }
+
+  @GET
+  @Path("/schema/similarity")
+  @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_ATOM_XML, 
BINARY_CONTENT_TYPE_V2})
+  @PermissionName(PermissionNameProvider.Name.SCHEMA_READ_PERM)
+  public SchemaSimilarityResponse getSchemaSimilarity() {
+    SchemaSimilarityResponse response = 
instantiateJerseyResponse(SchemaSimilarityResponse.class);
+
+    response.similarity =
+        
solrCore.getLatestSchema().getSimilarityFactory().getNamedPropertyValues();
+
+    return response;
   }
 
-  @EndPoint(
-      path = {"/schema/similarity"},
-      method = GET,
-      permission = PermissionNameProvider.Name.SCHEMA_READ_PERM)
-  public void getSchemaSimilarity(SolrQueryRequest req, SolrQueryResponse rsp) 
throws Exception {
-    schemaHandler.handleRequestBody(req, rsp);
+  public static class SchemaSimilarityResponse extends SolrJerseyResponse {
+    @JsonProperty("similarity")
+    SimpleOrderedMap<Object> similarity;

Review Comment:
   [-1] This field needs to be 'public', or else the Jackson serialization has 
trouble detecting it and adding it to the response 😬 (EDIT: It's actually not 
the Jackson serialization, but the introspection we do on v1 requests to 
"squash" the v2 response into the NamedList that Solr's v1 code expects)
   
   (I've fixed this in a commit I'll upload shortly, just mentioning it here as 
an FYI)



-- 
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: issues-unsubscr...@solr.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org
For additional commands, e-mail: issues-h...@solr.apache.org

Reply via email to