Double retrieveSchemaVersion(String collectionName) {
   try {
     SolrJsonResponse response =
         SolrSchemaRequest.version().process(factory.getSolrClient(collectionName));
     JsonNode node = response.getNode("version");
     return node != null ? node.asDouble() : Double.NaN;
   } catch (SolrServerException e) {
     EXCEPTION_TRANSLATOR.translateExceptionIfPossible(new RuntimeException(e));
   } catch (IOException e) {
     EXCEPTION_TRANSLATOR.translateExceptionIfPossible(new RuntimeException(e));
   } catch (SolrException e) {
     EXCEPTION_TRANSLATOR.translateExceptionIfPossible(new RuntimeException(e));
   }
   return Double.NaN;
 }
  SchemaDefinition loadExistingSchema(String collectionName) {

    try {
      SolrJsonResponse response =
          SolrSchemaRequest.schema().process(factory.getSolrClient(collectionName));
      if (response != null && response.getNode("schema") != null) {
        ObjectMapper mapper = new ObjectMapper();
        mapper.enable(MapperFeature.AUTO_DETECT_CREATORS);
        mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
        mapper.configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true);
        return mapper.readValue(response.getNode("schema").toString(), SchemaDefinition.class);
      }
      return null;
    } catch (SolrServerException e) {
      throw EXCEPTION_TRANSLATOR.translateExceptionIfPossible(new RuntimeException(e));
    } catch (IOException e) {
      throw new InvalidDataAccessResourceUsageException("Failed to load schema definition.", e);
    } catch (SolrException e) {
      throw EXCEPTION_TRANSLATOR.translateExceptionIfPossible(new RuntimeException(e));
    }
  }
 private void writeFieldDefinitions(
     Collection<FieldDefinition> definitions, String collectionName) {
   if (!CollectionUtils.isEmpty(definitions)) {
     try {
       SolrSchemaRequest.create()
           .fields(definitions)
           .build()
           .process(factory.getSolrClient(collectionName));
     } catch (SolrServerException e) {
       throw EXCEPTION_TRANSLATOR.translateExceptionIfPossible(new RuntimeException(e));
     } catch (IOException e) {
       throw new InvalidDataAccessResourceUsageException(
           "Failed to write schema field definitions.", e);
     }
   }
 }