public void changeFieldType(final CustomFieldMapping customMapping,
                                final Set<String> indexSetsIds,
                                final boolean rotateImmediately) {
        checkFieldTypeCanBeChanged(customMapping.fieldName());
        checkType(customMapping);
        checkAllIndicesSupportFieldTypeChange(customMapping.fieldName(), indexSetsIds);

        for (String indexSetId : indexSetsIds) {
            try {
                indexSetService.get(indexSetId).ifPresent(indexSetConfig -> {
                    var updatedIndexSetConfig = storeMapping(customMapping, indexSetConfig);
                    if (rotateImmediately) {
                        updatedIndexSetConfig.ifPresent(this::cycleIndexSet);
                    }
                });
            } catch (Exception ex) {
                LOG.error("Failed to update field type in index set : " + indexSetId, ex);
                throw ex;
            }
        }
    }
@Test
    void testThrowsExceptionOnIndexThatCannotHaveFieldTypeChanged() {
        IndexSetConfig illegalForFieldTypeChange = mock(IndexSetConfig.class);
        doReturn(Optional.of(illegalForFieldTypeChange)).when(indexSetService).get("existing_index_set");

        assertThrows(BadRequestException.class, () -> toTest.changeFieldType(newCustomMapping,
                Set.of("existing_index_set"),
                false));

        verifyNoInteractions(mongoIndexSetService);
    }