Make sure that IdFieldType#isAggregatable is accurate. (#62903)
Before, it always returned 'true' even when the setting "indices.id_field_data.enabled" was false. Fixes #62897.
This commit is contained in:
parent
2405162c39
commit
733e89d7ed
|
@ -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()
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue