diff --git a/server/src/test/java/org/elasticsearch/index/mapper/IdFieldMapperTests.java b/server/src/test/java/org/elasticsearch/index/mapper/IdFieldMapperTests.java index ea834a226da..ba2099acfc4 100644 --- a/server/src/test/java/org/elasticsearch/index/mapper/IdFieldMapperTests.java +++ b/server/src/test/java/org/elasticsearch/index/mapper/IdFieldMapperTests.java @@ -87,6 +87,7 @@ public class IdFieldMapperTests extends ESSingleNodeTestCase { throw new UnsupportedOperationException(); }).build(null, null); assertWarnings(ID_FIELD_DATA_DEPRECATION_MESSAGE); + assertTrue(ft.isAggregatable()); client().admin().cluster().prepareUpdateSettings() .setTransientSettings(Settings.builder().put(IndicesService.INDICES_ID_FIELD_DATA_ENABLED_SETTING.getKey(), false)) @@ -97,6 +98,7 @@ public class IdFieldMapperTests extends ESSingleNodeTestCase { throw new UnsupportedOperationException(); }).build(null, null)); assertThat(exc.getMessage(), containsString(IndicesService.INDICES_ID_FIELD_DATA_ENABLED_SETTING.getKey())); + assertFalse(ft.isAggregatable()); } finally { // unset cluster setting client().admin().cluster().prepareUpdateSettings() diff --git a/server/src/test/java/org/elasticsearch/index/mapper/IdFieldTypeTests.java b/server/src/test/java/org/elasticsearch/index/mapper/IdFieldTypeTests.java index 70571e263ad..80ec691c0dd 100644 --- a/server/src/test/java/org/elasticsearch/index/mapper/IdFieldTypeTests.java +++ b/server/src/test/java/org/elasticsearch/index/mapper/IdFieldTypeTests.java @@ -67,4 +67,12 @@ public class IdFieldTypeTests extends ESTestCase { query = ft.termQuery("id", context); assertEquals(new TermInSetQuery("_id", Uid.encodeId("id")), query); } + + public void testIsAggregatable() { + MappedFieldType ft = new IdFieldMapper.IdFieldType(() -> false); + assertFalse(ft.isAggregatable()); + + ft = new IdFieldMapper.IdFieldType(() -> true); + assertTrue(ft.isAggregatable()); + } }