Skip to content

Commit

Permalink
Make sure that IdFieldType#isAggregatable is accurate. (#62903)
Browse files Browse the repository at this point in the history
Before, it always returned 'true' even when the setting
"indices.id_field_data.enabled" was false.

Fixes #62897.
  • Loading branch information
jtibshirani committed Oct 6, 2020
1 parent 2405162 commit 733e89d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public void testEnableFieldData() throws IOException {
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))
Expand All @@ -97,6 +98,7 @@ public void testEnableFieldData() throws IOException {
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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,12 @@ public void testTermsQuery() {
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());
}
}

0 comments on commit 733e89d

Please sign in to comment.