private void configureDefaultAttributes() {
attributes.put("dynamic", valueOf(false));
- attributes.put("_all", ImmutableSortedMap.of(ENABLED, false));
attributes.put("_source", ImmutableSortedMap.of(ENABLED, true));
}
assertThat(newIndex.getRelations()).isEmpty();
}
+ @Test
+ @UseDataProvider("indexWithAndWithoutRelations")
+ public void does_not_enable_all_field(Index index) {
+ SimplestNewIndex newIndex = new SimplestNewIndex(IndexType.main(index, "foo"), defaultSettingsConfiguration);
+
+ // _all field is deprecated in 6.X and will be removed in 7.x and should not be used
+ assertThat(newIndex.getAttributes().get("_all")).isNull();
+ }
+
@Test
@UseDataProvider("indexWithAndWithoutRelations")
public void verify_default_index_settings_in_standalone(Index index) {
settings.setProperty(CLUSTER_ENABLED.getKey(), "true");
Settings underTest = new SimplestNewIndex(IndexType.main(index, "foo"), defaultSettingsConfiguration).getSettings().build();
+ // _all field is deprecated in ES 6.X and will be removed in 7.X
+ assertThat(underTest.get("_all")).isNull();
assertThat(underTest.get("index.number_of_shards")).isNotEmpty();
- // index.mapper.dynamic is deprecated and should not be set anymore
- assertThat(underTest.get("index.mapper.dynamic")).isNull();
assertThat(underTest.get("index.refresh_interval")).isEqualTo("30s");
// setting "mapping.single_type" has been dropped in 6.X because multi type indices are not supported anymore
assertThat(underTest.get("mapping.single_type")).isNull();
*/
package org.sonar.server.es;
-import com.google.common.collect.Sets;
import java.util.Arrays;
+import java.util.Map;
import java.util.Set;
import java.util.stream.Stream;
-import org.elasticsearch.action.admin.indices.mapping.get.GetMappingsResponse;
+import org.elasticsearch.action.admin.indices.stats.IndexStats;
import org.sonar.api.utils.log.Loggers;
+import org.sonar.core.util.stream.MoreCollectors;
import org.sonar.server.platform.db.migration.es.MigrationEsClient;
public class MigrationEsClientImpl implements MigrationEsClient {
@Override
public void deleteIndexes(String name, String... otherNames) {
- GetMappingsResponse mappings = client.nativeClient().admin().indices().prepareGetMappings("_all").get();
- Set<String> existingIndices = Sets.newHashSet(mappings.mappings().keysIt());
+ Map<String, IndexStats> indices = client.nativeClient().admin().indices().prepareStats().get().getIndices();
+ Set<String> existingIndices = indices.values().stream().map(IndexStats::getIndex).collect(MoreCollectors.toSet());
Stream.concat(Stream.of(name), Arrays.stream(otherNames))
.distinct()
.filter(existingIndices::contains)