public boolean removeMapping(String collectionName, List<Map<String, Object>> mapping) throws DatastoreClientServiceException { Boolean result = true; try { for (Map<String, Object> field: mapping) { SchemaRequest.DeleteField schemaRequest = new SchemaRequest.DeleteField((String) field.get("name")); SchemaResponse.UpdateResponse response = schemaRequest.process(getClient(), collectionName); result = result && response.getStatus() == 0 && response.getResponse().get("errors") == null; } getClient().commit(collectionName); refreshCollection(collectionName); return result; } catch (Exception e) { logger.error(e.getMessage()); } return false; }
@Override public void removeField(final String name) { template.execute(solrClient -> { try { UpdateResponse response = new SchemaRequest.DeleteField(name).process(solrClient, collection); if (hasErrors(response)) { throw new SchemaModificationException( String.format("Removing field with name %s from collection %s failed with status %s. Server returned %s.", name, collection, response.getStatus(), response)); } return Integer.valueOf(response.getStatus()); } catch (Exception e) { throw new SchemaModificationException( String.format("Removing field with name %s from collection %s failed.", name, collection)); } }); }
public DeleteField(String fieldName, SolrParams q) { super(createRequestParameters(fieldName), q); }
public DeleteField(String fieldName, SolrParams q) { super(createRequestParameters(fieldName), q); }