Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve the error message when an index is incompatible with field aliases. #32482

Merged
merged 1 commit into from
Jul 31, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ public void testSerializationFailsUnlessFetched() throws IOException {
}

public void testFieldAlias() throws IOException {
assumeTrue("Test only runs when there is a single mapping type.", isSingleType());
assumeTrue("Test only runs on indexes that enforce a single mapping type.", isSingleType());

QueryShardContext shardContext = createShardContext();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ public Mapper.Builder parse(String name, Map<String, Object> node, ParserContext
private static void checkIndexCompatibility(IndexSettings settings, String name) {
if (!settings.isSingleType()) {
throw new IllegalStateException("Cannot create a field alias [" + name + "] " +
"on index [" + settings.getIndex().getName() + "], as it has multiple types.");
"for index [" + settings.getIndex().getName() + "]. Field aliases can only " +
"be specified on indexes that enforce a single mapping type.");
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ public void testFieldAliasDisallowedWithMultipleTypes() throws IOException {
.endObject());
IllegalStateException e = expectThrows(IllegalStateException.class,
() -> parser.parse("type", new CompressedXContent(mapping)));
assertEquals("Cannot create a field alias [alias-field] on index [alias-test],"
+ " as it has multiple types.", e.getMessage());
assertEquals("Cannot create a field alias [alias-field] for index [alias-test]. Field aliases" +
" can only be specified on indexes that enforce a single mapping type.", e.getMessage());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ public void testDoToQuery_msmScriptField() throws Exception {
}

public void testFieldAlias() {
assumeTrue("Test runs only when there is a single mapping type.", isSingleType());
assumeTrue("Test only runs on indexes that enforce a single mapping type.", isSingleType());

List<String> randomTerms = Arrays.asList(generateRandomStringArray(5, 10, false, false));
TermsSetQueryBuilder queryBuilder = new TermsSetQueryBuilder(STRING_ALIAS_FIELD_NAME, randomTerms)
Expand Down