Skip to content

Commit

Permalink
Improve the error message when an index is incompatible with field al…
Browse files Browse the repository at this point in the history
…iases. (#32482)
  • Loading branch information
jtibshirani authored Jul 31, 2018
1 parent 3b4c76e commit adeec7e
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
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

0 comments on commit adeec7e

Please sign in to comment.