Skip to content

Commit

Permalink
Switch include_in_all in multifield to warning
Browse files Browse the repository at this point in the history
This reverts elastic#21971 which should only have been applied in master
to preserve backwards compatibility. Instead of throwing an error
when you specify `include_in_all` inside a multifield we instead
return a deprecation warning. `include_in_all` in a multifield
still doesn't do anything. But at least people who use it erroneously
won't break.

Closes elastic#23654
  • Loading branch information
nik9000 committed Mar 20, 2017
1 parent 4af7b03 commit 8ae210b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,9 @@ && parseNorms(builder, name, propName, propNode, parserContext)) {
iterator.remove();
} else if (propName.equals("include_in_all")) {
if (parserContext.isWithinMultiField()) {
throw new MapperParsingException("include_in_all in multi fields is not allowed. Found the include_in_all in field ["
+ name + "] which is within a multi field.");
deprecationLogger.deprecated("include_in_all in multi fields is deprecated "
+ "because it doesn't do anything. Found the include_in_all in field "
+ "[{}] which is within a multi field.", name);
} else {
deprecationLogger.deprecated("field [include_in_all] is deprecated, as [_all] is deprecated, " +
"and will be disallowed in 6.0, use [copy_to] instead.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,11 @@ public class MultiFieldIncludeInAllMapperTests extends ESTestCase {
public void testExceptionForIncludeInAllInMultiFields() throws IOException {
XContentBuilder mapping = createMappingWithIncludeInAllInMultiField();

// first check that for newer versions we throw exception if include_in_all is found withing multi field
// first check that for newer versions we throw exception if include_in_all is found within multi field
MapperService mapperService = MapperTestUtils.newMapperService(xContentRegistry(), createTempDir(), Settings.EMPTY);
Exception e = expectThrows(MapperParsingException.class, () ->
mapperService.parse("type", new CompressedXContent(mapping.string()), true));
assertEquals("include_in_all in multi fields is not allowed. Found the include_in_all in field [c] which is within a multi field.",
e.getMessage());
mapperService.parse("type", new CompressedXContent(mapping.string()), true);
assertWarnings("include_in_all in multi fields is deprecated because it doesn't do "
+ "anything. Found the include_in_all in field [c] which is within a multi field.");
}

private static XContentBuilder createMappingWithIncludeInAllInMultiField() throws IOException {
Expand Down

0 comments on commit 8ae210b

Please sign in to comment.