diff --git a/buildSrc/src/main/resources/checkstyle_suppressions.xml b/buildSrc/src/main/resources/checkstyle_suppressions.xml
index 36da839d03e57..6a07c9058c836 100644
--- a/buildSrc/src/main/resources/checkstyle_suppressions.xml
+++ b/buildSrc/src/main/resources/checkstyle_suppressions.xml
@@ -128,29 +128,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -276,33 +253,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/server/src/main/java/org/elasticsearch/index/mapper/CompletionFieldMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/CompletionFieldMapper.java
index deb88d13fef4e..c63976387d8af 100644
--- a/server/src/main/java/org/elasticsearch/index/mapper/CompletionFieldMapper.java
+++ b/server/src/main/java/org/elasticsearch/index/mapper/CompletionFieldMapper.java
@@ -117,7 +117,8 @@ public static class Fields {
public static class TypeParser implements Mapper.TypeParser {
@Override
- public Mapper.Builder, ?> parse(String name, Map node, ParserContext parserContext) throws MapperParsingException {
+ public Mapper.Builder, ?> parse(String name, Map node, ParserContext parserContext)
+ throws MapperParsingException {
CompletionFieldMapper.Builder builder = new CompletionFieldMapper.Builder(name);
NamedAnalyzer indexAnalyzer = null;
NamedAnalyzer searchAnalyzer = null;
@@ -368,7 +369,8 @@ public Builder(String name) {
*/
public Builder maxInputLength(int maxInputLength) {
if (maxInputLength <= 0) {
- throw new IllegalArgumentException(Fields.MAX_INPUT_LENGTH.getPreferredName() + " must be > 0 but was [" + maxInputLength + "]");
+ throw new IllegalArgumentException(Fields.MAX_INPUT_LENGTH.getPreferredName()
+ + " must be > 0 but was [" + maxInputLength + "]");
}
this.maxInputLength = maxInputLength;
return this;
@@ -400,13 +402,15 @@ public CompletionFieldMapper build(BuilderContext context) {
completionFieldType.setContextMappings(contextMappings);
completionFieldType.setPreservePositionIncrements(preservePositionIncrements);
completionFieldType.setPreserveSep(preserveSeparators);
- return new CompletionFieldMapper(name, this.fieldType, context.indexSettings(), multiFieldsBuilder.build(this, context), copyTo, maxInputLength);
+ return new CompletionFieldMapper(name, this.fieldType, context.indexSettings(),
+ multiFieldsBuilder.build(this, context), copyTo, maxInputLength);
}
}
private int maxInputLength;
- public CompletionFieldMapper(String simpleName, MappedFieldType fieldType, Settings indexSettings, MultiFields multiFields, CopyTo copyTo, int maxInputLength) {
+ public CompletionFieldMapper(String simpleName, MappedFieldType fieldType, Settings indexSettings,
+ MultiFields multiFields, CopyTo copyTo, int maxInputLength) {
super(simpleName, fieldType, Defaults.FIELD_TYPE, indexSettings, multiFields, copyTo);
this.maxInputLength = maxInputLength;
}
@@ -506,7 +510,8 @@ private boolean isExternalValueOfClass(ParseContext context, Class> clazz) {
* "STRING" - interpreted as the field value (input)
* "OBJECT" - { "input": STRING|ARRAY, "weight": STRING|INT, "contexts": ARRAY|OBJECT }
*/
- private void parse(ParseContext parseContext, Token token, XContentParser parser, Map inputMap) throws IOException {
+ private void parse(ParseContext parseContext, Token token,
+ XContentParser parser, Map inputMap) throws IOException {
String currentFieldName = null;
if (token == Token.VALUE_STRING) {
inputMap.put(parser.text(), new CompletionInputMetaData(parser.text(), Collections.emptyMap(), 1));
@@ -518,7 +523,8 @@ private void parse(ParseContext parseContext, Token token, XContentParser parser
if (token == Token.FIELD_NAME) {
currentFieldName = parser.currentName();
if (!ALLOWED_CONTENT_FIELD_NAMES.contains(currentFieldName)) {
- throw new IllegalArgumentException("unknown field name [" + currentFieldName + "], must be one of " + ALLOWED_CONTENT_FIELD_NAMES);
+ throw new IllegalArgumentException("unknown field name [" + currentFieldName
+ + "], must be one of " + ALLOWED_CONTENT_FIELD_NAMES);
}
} else if (currentFieldName != null) {
if (Fields.CONTENT_FIELD_NAME_INPUT.equals(currentFieldName)) {
@@ -529,7 +535,8 @@ private void parse(ParseContext parseContext, Token token, XContentParser parser
if (token == Token.VALUE_STRING) {
inputs.add(parser.text());
} else {
- throw new IllegalArgumentException("input array must have string values, but was [" + token.name() + "]");
+ throw new IllegalArgumentException("input array must have string values, but was ["
+ + token.name() + "]");
}
}
} else {
@@ -552,8 +559,10 @@ private void parse(ParseContext parseContext, Token token, XContentParser parser
} else {
throw new IllegalArgumentException("weight must be a number or string, but was [" + token.name() + "]");
}
- if (weightValue.longValue() < 0 || weightValue.longValue() > Integer.MAX_VALUE) { // always parse a long to make sure we don't get overflow
- throw new IllegalArgumentException("weight must be in the interval [0..2147483647], but was [" + weightValue.longValue() + "]");
+ // always parse a long to make sure we don't get overflow
+ if (weightValue.longValue() < 0 || weightValue.longValue() > Integer.MAX_VALUE) {
+ throw new IllegalArgumentException("weight must be in the interval [0..2147483647], but was ["
+ + weightValue.longValue() + "]");
}
weight = weightValue.intValue();
} else if (Fields.CONTENT_FIELD_NAME_CONTEXTS.equals(currentFieldName)) {
@@ -587,7 +596,8 @@ private void parse(ParseContext parseContext, Token token, XContentParser parser
}
}
} else {
- throw new ParsingException(parser.getTokenLocation(), "failed to parse [" + parser.currentName() + "]: expected text or object, but got " + token.name());
+ throw new ParsingException(parser.getTokenLocation(), "failed to parse [" + parser.currentName()
+ + "]: expected text or object, but got " + token.name());
}
}
diff --git a/server/src/main/java/org/elasticsearch/index/mapper/DocumentMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/DocumentMapper.java
index 2d3cd655d28ff..ec3635611a98e 100644
--- a/server/src/main/java/org/elasticsearch/index/mapper/DocumentMapper.java
+++ b/server/src/main/java/org/elasticsearch/index/mapper/DocumentMapper.java
@@ -71,8 +71,9 @@ public Builder(RootObjectMapper.Builder builder, MapperService mapperService) {
this.rootObjectMapper = builder.build(builderContext);
final String type = rootObjectMapper.name();
- DocumentMapper existingMapper = mapperService.documentMapper(type);
- for (Map.Entry entry : mapperService.mapperRegistry.getMetadataMapperParsers().entrySet()) {
+ final DocumentMapper existingMapper = mapperService.documentMapper(type);
+ final Map metadataMapperParsers = mapperService.mapperRegistry.getMetadataMapperParsers();
+ for (Map.Entry entry : metadataMapperParsers.entrySet()) {
final String name = entry.getKey();
final MetadataFieldMapper existingMetadataMapper = existingMapper == null
? null
diff --git a/server/src/main/java/org/elasticsearch/index/mapper/DocumentParser.java b/server/src/main/java/org/elasticsearch/index/mapper/DocumentParser.java
index ef85ee7127acd..f7913e895e772 100644
--- a/server/src/main/java/org/elasticsearch/index/mapper/DocumentParser.java
+++ b/server/src/main/java/org/elasticsearch/index/mapper/DocumentParser.java
@@ -107,7 +107,8 @@ private void validateType(SourceToParse source) {
}
if (Objects.equals(source.type(), docMapper.type()) == false) {
- throw new MapperParsingException("Type mismatch, provide type [" + source.type() + "] but mapper is of type [" + docMapper.type() + "]");
+ throw new MapperParsingException("Type mismatch, provide type [" + source.type() + "] but mapper is of type ["
+ + docMapper.type() + "]");
}
}
@@ -136,7 +137,8 @@ private static boolean isEmptyDoc(Mapping mapping, XContentParser parser) throws
// empty doc, we can handle it...
return true;
} else if (token != XContentParser.Token.FIELD_NAME) {
- throw new MapperParsingException("Malformed content, after first object, either the type field or the actual properties should exist");
+ throw new MapperParsingException("Malformed content, after first object, either the type field"
+ + " or the actual properties should exist");
}
}
return false;
@@ -355,7 +357,8 @@ static void parseObjectOrNested(ParseContext context, ObjectMapper mapper) throw
String currentFieldName = parser.currentName();
if (token.isValue()) {
- throw new MapperParsingException("object mapping for [" + mapper.name() + "] tried to parse field [" + currentFieldName + "] as object, but found a concrete value");
+ throw new MapperParsingException("object mapping for [" + mapper.name() + "] tried to parse field [" + currentFieldName
+ + "] as object, but found a concrete value");
}
ObjectMapper.Nested nested = mapper.nested();
@@ -385,7 +388,8 @@ static void parseObjectOrNested(ParseContext context, ObjectMapper mapper) throw
}
}
- private static void innerParseObject(ParseContext context, ObjectMapper mapper, XContentParser parser, String currentFieldName, XContentParser.Token token) throws IOException {
+ private static void innerParseObject(ParseContext context, ObjectMapper mapper, XContentParser parser,
+ String currentFieldName, XContentParser.Token token) throws IOException {
while (token != XContentParser.Token.END_OBJECT) {
if (token == XContentParser.Token.START_OBJECT) {
parseObject(context, mapper, currentFieldName);
@@ -394,12 +398,14 @@ private static void innerParseObject(ParseContext context, ObjectMapper mapper,
} else if (token == XContentParser.Token.FIELD_NAME) {
currentFieldName = parser.currentName();
if (MapperService.isMetadataField(context.path().pathAsText(currentFieldName))) {
- throw new MapperParsingException("Field [" + currentFieldName + "] is a metadata field and cannot be added inside a document. Use the index API request parameters.");
+ throw new MapperParsingException("Field [" + currentFieldName + "] is a metadata field and cannot be added inside"
+ + " a document. Use the index API request parameters.");
}
} else if (token == XContentParser.Token.VALUE_NULL) {
parseNullValue(context, mapper, currentFieldName);
} else if (token == null) {
- throw new MapperParsingException("object mapping for [" + mapper.name() + "] tried to parse field [" + currentFieldName + "] as object, but got EOF, has a concrete value been provided to it?");
+ throw new MapperParsingException("object mapping for [" + mapper.name() + "] tried to parse field [" + currentFieldName
+ + "] as object, but got EOF, has a concrete value been provided to it?");
} else if (token.isValue()) {
parseValue(context, mapper, currentFieldName, token);
}
@@ -575,7 +581,8 @@ private static void parseArray(ParseContext context, ObjectMapper parentMapper,
}
}
- private static void parseNonDynamicArray(ParseContext context, ObjectMapper mapper, String lastFieldName, String arrayFieldName) throws IOException {
+ private static void parseNonDynamicArray(ParseContext context, ObjectMapper mapper,
+ String lastFieldName, String arrayFieldName) throws IOException {
XContentParser parser = context.parser();
XContentParser.Token token;
while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
@@ -588,16 +595,19 @@ private static void parseNonDynamicArray(ParseContext context, ObjectMapper mapp
} else if (token == XContentParser.Token.VALUE_NULL) {
parseNullValue(context, mapper, lastFieldName);
} else if (token == null) {
- throw new MapperParsingException("object mapping for [" + mapper.name() + "] with array for [" + arrayFieldName + "] tried to parse as array, but got EOF, is there a mismatch in types for the same field?");
+ throw new MapperParsingException("object mapping for [" + mapper.name() + "] with array for [" + arrayFieldName
+ + "] tried to parse as array, but got EOF, is there a mismatch in types for the same field?");
} else {
parseValue(context, mapper, lastFieldName, token);
}
}
}
- private static void parseValue(final ParseContext context, ObjectMapper parentMapper, String currentFieldName, XContentParser.Token token) throws IOException {
+ private static void parseValue(final ParseContext context, ObjectMapper parentMapper,
+ String currentFieldName, XContentParser.Token token) throws IOException {
if (currentFieldName == null) {
- throw new MapperParsingException("object mapping [" + parentMapper.name() + "] trying to serialize a value with no field associated with it, current value [" + context.parser().textOrNull() + "]");
+ throw new MapperParsingException("object mapping [" + parentMapper.name() + "] trying to serialize a value with"
+ + " no field associated with it, current value [" + context.parser().textOrNull() + "]");
}
final String[] paths = splitAndValidatePath(currentFieldName);
@@ -626,7 +636,8 @@ private static void parseNullValue(ParseContext context, ObjectMapper parentMapp
}
}
- private static Mapper.Builder,?> createBuilderFromFieldType(final ParseContext context, MappedFieldType fieldType, String currentFieldName) {
+ private static Mapper.Builder,?> createBuilderFromFieldType(final ParseContext context,
+ MappedFieldType fieldType, String currentFieldName) {
Mapper.Builder builder = null;
if (fieldType instanceof TextFieldType) {
builder = context.root().findTemplateBuilder(context, currentFieldName, "text", XContentFieldType.STRING);
@@ -688,7 +699,9 @@ private static Mapper.Builder,?> createBuilderFromFieldType(final ParseContext
return builder;
}
- private static Mapper.Builder,?> createBuilderFromDynamicValue(final ParseContext context, XContentParser.Token token, String currentFieldName) throws IOException {
+ private static Mapper.Builder,?> createBuilderFromDynamicValue(final ParseContext context,
+ XContentParser.Token token,
+ String currentFieldName) throws IOException {
if (token == XContentParser.Token.VALUE_STRING) {
String text = context.parser().text();
@@ -788,10 +801,12 @@ private static Mapper.Builder,?> createBuilderFromDynamicValue(final ParseCont
}
}
// TODO how do we identify dynamically that its a binary value?
- throw new IllegalStateException("Can't handle serializing a dynamic type with content token [" + token + "] and field name [" + currentFieldName + "]");
+ throw new IllegalStateException("Can't handle serializing a dynamic type with content token [" + token + "] and field name ["
+ + currentFieldName + "]");
}
- private static void parseDynamicValue(final ParseContext context, ObjectMapper parentMapper, String currentFieldName, XContentParser.Token token) throws IOException {
+ private static void parseDynamicValue(final ParseContext context, ObjectMapper parentMapper,
+ String currentFieldName, XContentParser.Token token) throws IOException {
ObjectMapper.Dynamic dynamic = dynamicOrDefault(parentMapper, context);
if (dynamic == ObjectMapper.Dynamic.STRICT) {
throw new StrictDynamicMappingException(parentMapper.fullPath(), currentFieldName);
@@ -902,8 +917,8 @@ private static Tuple getDynamicParentMapper(ParseContext
context.path());
mapper = (ObjectMapper) builder.build(builderContext);
if (mapper.nested() != ObjectMapper.Nested.NO) {
- throw new MapperParsingException("It is forbidden to create dynamic nested objects ([" + context.path().pathAsText(paths[i])
- + "]) through `copy_to` or dots in field names");
+ throw new MapperParsingException("It is forbidden to create dynamic nested objects (["
+ + context.path().pathAsText(paths[i]) + "]) through `copy_to` or dots in field names");
}
context.addDynamicMapper(mapper);
break;
diff --git a/server/src/main/java/org/elasticsearch/index/mapper/DynamicTemplate.java b/server/src/main/java/org/elasticsearch/index/mapper/DynamicTemplate.java
index 97b973934d016..eeaefebfe4ce9 100644
--- a/server/src/main/java/org/elasticsearch/index/mapper/DynamicTemplate.java
+++ b/server/src/main/java/org/elasticsearch/index/mapper/DynamicTemplate.java
@@ -228,7 +228,8 @@ public static DynamicTemplate parse(String name, Map conf,
try {
matchType.matches(regex, "");
} catch (IllegalArgumentException e) {
- throw new IllegalArgumentException("Pattern [" + regex + "] of type [" + matchType + "] is invalid. Cannot create dynamic template [" + name + "].", e);
+ throw new IllegalArgumentException("Pattern [" + regex + "] of type [" + matchType
+ + "] is invalid. Cannot create dynamic template [" + name + "].", e);
}
}
}
@@ -320,14 +321,16 @@ public Map mappingForName(String name, String dynamicType) {
private Map processMap(Map map, String name, String dynamicType) {
Map processedMap = new HashMap<>();
for (Map.Entry entry : map.entrySet()) {
- String key = entry.getKey().replace("{name}", name).replace("{dynamic_type}", dynamicType).replace("{dynamicType}", dynamicType);
+ String key = entry.getKey().replace("{name}", name).replace("{dynamic_type}", dynamicType)
+ .replace("{dynamicType}", dynamicType);
Object value = entry.getValue();
if (value instanceof Map) {
value = processMap((Map) value, name, dynamicType);
} else if (value instanceof List) {
value = processList((List) value, name, dynamicType);
} else if (value instanceof String) {
- value = value.toString().replace("{name}", name).replace("{dynamic_type}", dynamicType).replace("{dynamicType}", dynamicType);
+ value = value.toString().replace("{name}", name).replace("{dynamic_type}", dynamicType)
+ .replace("{dynamicType}", dynamicType);
}
processedMap.put(key, value);
}
@@ -342,7 +345,9 @@ private List processList(List list, String name, String dynamicType) {
} else if (value instanceof List) {
value = processList((List) value, name, dynamicType);
} else if (value instanceof String) {
- value = value.toString().replace("{name}", name).replace("{dynamic_type}", dynamicType).replace("{dynamicType}", dynamicType);
+ value = value.toString().replace("{name}", name)
+ .replace("{dynamic_type}", dynamicType)
+ .replace("{dynamicType}", dynamicType);
}
processedList.add(value);
}
diff --git a/server/src/main/java/org/elasticsearch/index/mapper/FieldMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/FieldMapper.java
index 0a5ecc9e7a82b..24f07c07d34d5 100644
--- a/server/src/main/java/org/elasticsearch/index/mapper/FieldMapper.java
+++ b/server/src/main/java/org/elasticsearch/index/mapper/FieldMapper.java
@@ -92,7 +92,8 @@ public T index(boolean index) {
// can happen when an existing type on the same index has disabled indexing
// since we inherit the default field type from the first mapper that is
// created on an index
- throw new IllegalArgumentException("mapper [" + name + "] has different [index] values from other types of the same index");
+ throw new IllegalArgumentException("mapper [" + name + "] has different [index] values from other types"
+ + " of the same index");
}
fieldType.setIndexOptions(options);
}
@@ -248,7 +249,8 @@ protected void setupFieldType(BuilderContext context) {
protected MultiFields multiFields;
protected CopyTo copyTo;
- protected FieldMapper(String simpleName, MappedFieldType fieldType, MappedFieldType defaultFieldType, Settings indexSettings, MultiFields multiFields, CopyTo copyTo) {
+ protected FieldMapper(String simpleName, MappedFieldType fieldType, MappedFieldType defaultFieldType,
+ Settings indexSettings, MultiFields multiFields, CopyTo copyTo) {
super(simpleName);
assert indexSettings != null;
this.indexCreatedVersion = Version.indexCreated(indexSettings);
@@ -349,7 +351,8 @@ protected void doMerge(Mapper mergeWith, boolean updateAllTypes) {
if (mergeWith instanceof FieldMapper) {
mergedType = ((FieldMapper) mergeWith).contentType();
}
- throw new IllegalArgumentException("mapper [" + fieldType().name() + "] of different type, current_type [" + contentType() + "], merged_type [" + mergedType + "]");
+ throw new IllegalArgumentException("mapper [" + fieldType().name() + "] of different type, current_type [" + contentType()
+ + "], merged_type [" + mergedType + "]");
}
FieldMapper fieldMergeWith = (FieldMapper) mergeWith;
multiFields = multiFields.merge(fieldMergeWith.multiFields);
@@ -438,12 +441,13 @@ protected final void doXContentAnalyzers(XContentBuilder builder, boolean includ
}
} else {
boolean hasDefaultIndexAnalyzer = fieldType().indexAnalyzer().name().equals("default");
- boolean hasDifferentSearchAnalyzer = fieldType().searchAnalyzer().name().equals(fieldType().indexAnalyzer().name()) == false;
- boolean hasDifferentSearchQuoteAnalyzer = fieldType().searchAnalyzer().name().equals(fieldType().searchQuoteAnalyzer().name()) == false;
+ final String searchAnalyzerName = fieldType().searchAnalyzer().name();
+ boolean hasDifferentSearchAnalyzer = searchAnalyzerName.equals(fieldType().indexAnalyzer().name()) == false;
+ boolean hasDifferentSearchQuoteAnalyzer = searchAnalyzerName.equals(fieldType().searchQuoteAnalyzer().name()) == false;
if (includeDefaults || hasDefaultIndexAnalyzer == false || hasDifferentSearchAnalyzer || hasDifferentSearchQuoteAnalyzer) {
builder.field("analyzer", fieldType().indexAnalyzer().name());
if (includeDefaults || hasDifferentSearchAnalyzer || hasDifferentSearchQuoteAnalyzer) {
- builder.field("search_analyzer", fieldType().searchAnalyzer().name());
+ builder.field("search_analyzer", searchAnalyzerName);
if (includeDefaults || hasDifferentSearchQuoteAnalyzer) {
builder.field("search_quote_analyzer", fieldType().searchQuoteAnalyzer().name());
}
@@ -545,7 +549,8 @@ private MultiFields(ImmutableOpenMap mappers) {
}
public void parse(FieldMapper mainField, ParseContext context) throws IOException {
- // TODO: multi fields are really just copy fields, we just need to expose "sub fields" or something that can be part of the mappings
+ // TODO: multi fields are really just copy fields, we just need to expose "sub fields" or something that can be part
+ // of the mappings
if (mappers.isEmpty()) {
return;
}
diff --git a/server/src/main/java/org/elasticsearch/index/mapper/FieldNamesFieldMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/FieldNamesFieldMapper.java
index 884470214ba8c..60cc563504249 100644
--- a/server/src/main/java/org/elasticsearch/index/mapper/FieldNamesFieldMapper.java
+++ b/server/src/main/java/org/elasticsearch/index/mapper/FieldNamesFieldMapper.java
@@ -103,7 +103,8 @@ public FieldNamesFieldMapper build(BuilderContext context) {
public static class TypeParser implements MetadataFieldMapper.TypeParser {
@Override
- public MetadataFieldMapper.Builder,?> parse(String name, Map node, ParserContext parserContext) throws MapperParsingException {
+ public MetadataFieldMapper.Builder,?> parse(String name, Map node,
+ ParserContext parserContext) throws MapperParsingException {
Builder builder = new Builder(parserContext.mapperService().fullName(NAME));
for (Iterator> iterator = node.entrySet().iterator(); iterator.hasNext();) {
@@ -170,7 +171,8 @@ public void checkCompatibility(MappedFieldType fieldType, List conflicts
if (strict) {
FieldNamesFieldType other = (FieldNamesFieldType)fieldType;
if (isEnabled() != other.isEnabled()) {
- conflicts.add("mapper [" + name() + "] is used by multiple types. Set update_all_types to true to update [enabled] across all types.");
+ conflicts.add("mapper [" + name() + "] is used by multiple types. Set update_all_types to true to update [enabled]"
+ + " across all types.");
}
}
}
diff --git a/server/src/main/java/org/elasticsearch/index/mapper/GeoShapeFieldMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/GeoShapeFieldMapper.java
index 48c68b8f3fee7..888bba664de0d 100644
--- a/server/src/main/java/org/elasticsearch/index/mapper/GeoShapeFieldMapper.java
+++ b/server/src/main/java/org/elasticsearch/index/mapper/GeoShapeFieldMapper.java
@@ -210,7 +210,8 @@ public Mapper.Builder parse(String name, Map node, ParserContext
builder.fieldType().setTreeLevels(Integer.parseInt(fieldNode.toString()));
iterator.remove();
} else if (Names.TREE_PRESISION.equals(fieldName)) {
- builder.fieldType().setPrecisionInMeters(DistanceUnit.parse(fieldNode.toString(), DistanceUnit.DEFAULT, DistanceUnit.DEFAULT));
+ builder.fieldType().setPrecisionInMeters(DistanceUnit.parse(fieldNode.toString(),
+ DistanceUnit.DEFAULT, DistanceUnit.DEFAULT));
iterator.remove();
} else if (Names.DISTANCE_ERROR_PCT.equals(fieldName)) {
builder.fieldType().setDistanceErrorPct(Double.parseDouble(fieldNode.toString()));
@@ -222,13 +223,15 @@ public Mapper.Builder parse(String name, Map node, ParserContext
builder.fieldType().setStrategyName(fieldNode.toString());
iterator.remove();
} else if (IGNORE_MALFORMED.equals(fieldName)) {
- builder.ignoreMalformed(TypeParsers.nodeBooleanValue(fieldName, "ignore_malformed", fieldNode, parserContext));
+ builder.ignoreMalformed(TypeParsers.nodeBooleanValue(fieldName, "ignore_malformed",
+ fieldNode, parserContext));
iterator.remove();
} else if (Names.COERCE.equals(fieldName)) {
builder.coerce(TypeParsers.nodeBooleanValue(fieldName, Names.COERCE, fieldNode, parserContext));
iterator.remove();
} else if (GeoPointFieldMapper.Names.IGNORE_Z_VALUE.getPreferredName().equals(fieldName)) {
- builder.ignoreZValue(TypeParsers.nodeBooleanValue(fieldName, GeoPointFieldMapper.Names.IGNORE_Z_VALUE.getPreferredName(),
+ builder.ignoreZValue(TypeParsers.nodeBooleanValue(fieldName,
+ GeoPointFieldMapper.Names.IGNORE_Z_VALUE.getPreferredName(),
fieldNode, parserContext));
iterator.remove();
} else if (Names.STRATEGY_POINTS_ONLY.equals(fieldName)) {
@@ -314,11 +317,14 @@ public void freeze() {
// must be by the time freeze is called.
SpatialPrefixTree prefixTree;
if ("geohash".equals(tree)) {
- prefixTree = new GeohashPrefixTree(ShapeBuilder.SPATIAL_CONTEXT, getLevels(treeLevels, precisionInMeters, Defaults.GEOHASH_LEVELS, true));
+ prefixTree = new GeohashPrefixTree(ShapeBuilder.SPATIAL_CONTEXT,
+ getLevels(treeLevels, precisionInMeters, Defaults.GEOHASH_LEVELS, true));
} else if ("legacyquadtree".equals(tree)) {
- prefixTree = new QuadPrefixTree(ShapeBuilder.SPATIAL_CONTEXT, getLevels(treeLevels, precisionInMeters, Defaults.QUADTREE_LEVELS, false));
+ prefixTree = new QuadPrefixTree(ShapeBuilder.SPATIAL_CONTEXT,
+ getLevels(treeLevels, precisionInMeters, Defaults.QUADTREE_LEVELS, false));
} else if ("quadtree".equals(tree)) {
- prefixTree = new PackedQuadPrefixTree(ShapeBuilder.SPATIAL_CONTEXT, getLevels(treeLevels, precisionInMeters, Defaults.QUADTREE_LEVELS, false));
+ prefixTree = new PackedQuadPrefixTree(ShapeBuilder.SPATIAL_CONTEXT,
+ getLevels(treeLevels, precisionInMeters, Defaults.QUADTREE_LEVELS, false));
} else {
throw new IllegalArgumentException("Unknown prefix tree type [" + tree + "]");
}
@@ -361,10 +367,12 @@ public void checkCompatibility(MappedFieldType fieldType, List conflicts
if (strict) {
if (orientation() != other.orientation()) {
- conflicts.add("mapper [" + name() + "] is used by multiple types. Set update_all_types to true to update [orientation] across all types.");
+ conflicts.add("mapper [" + name() + "] is used by multiple types. Set update_all_types to true to update"
+ + " [orientation] across all types.");
}
if (distanceErrorPct() != other.distanceErrorPct()) {
- conflicts.add("mapper [" + name() + "] is used by multiple types. Set update_all_types to true to update [distance_error_pct] across all types.");
+ conflicts.add("mapper [" + name() + "] is used by multiple types. Set update_all_types to true to update"
+ + " [distance_error_pct] across all types.");
}
}
}
@@ -512,8 +520,9 @@ public void parse(ParseContext context) throws IOException {
}
return;
} else if (shape instanceof Point == false) {
- throw new MapperParsingException("[{" + fieldType().name() + "}] is configured for points only but a " +
- ((shape instanceof JtsGeometry) ? ((JtsGeometry)shape).getGeom().getGeometryType() : shape.getClass()) + " was found");
+ throw new MapperParsingException("[{" + fieldType().name() + "}] is configured for points only but a "
+ + ((shape instanceof JtsGeometry) ? ((JtsGeometry)shape).getGeom().getGeometryType() : shape.getClass())
+ + " was found");
}
}
indexShape(context, shape);
diff --git a/server/src/main/java/org/elasticsearch/index/mapper/IdFieldMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/IdFieldMapper.java
index ac8ff76018003..a4114759772fe 100644
--- a/server/src/main/java/org/elasticsearch/index/mapper/IdFieldMapper.java
+++ b/server/src/main/java/org/elasticsearch/index/mapper/IdFieldMapper.java
@@ -86,7 +86,8 @@ public static class Defaults {
public static class TypeParser implements MetadataFieldMapper.TypeParser {
@Override
- public MetadataFieldMapper.Builder parse(String name, Map node, ParserContext parserContext) throws MapperParsingException {
+ public MetadataFieldMapper.Builder parse(String name, Map node,
+ ParserContext parserContext) throws MapperParsingException {
throw new MapperParsingException(NAME + " is not configurable");
}
@@ -171,7 +172,8 @@ public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) {
@Override
public IndexFieldData> build(IndexSettings indexSettings, MappedFieldType fieldType, IndexFieldDataCache cache,
CircuitBreakerService breakerService, MapperService mapperService) {
- final IndexFieldData> fieldData = fieldDataBuilder.build(indexSettings, fieldType, cache, breakerService, mapperService);
+ final IndexFieldData> fieldData = fieldDataBuilder.build(indexSettings, fieldType, cache,
+ breakerService, mapperService);
if (indexSettings.getIndexVersionCreated().before(Version.V_6_0_0_beta1)) {
// ids were indexed as utf-8
return fieldData;
@@ -200,7 +202,8 @@ public AtomicFieldData loadDirect(LeafReaderContext context) throws Exception {
@Override
public SortField sortField(Object missingValue, MultiValueMode sortMode, Nested nested, boolean reverse) {
- XFieldComparatorSource source = new BytesRefFieldComparatorSource(this, missingValue, sortMode, nested);
+ XFieldComparatorSource source = new BytesRefFieldComparatorSource(this, missingValue,
+ sortMode, nested);
return new SortField(getFieldName(), source, reverse);
}
diff --git a/server/src/main/java/org/elasticsearch/index/mapper/IndexFieldMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/IndexFieldMapper.java
index 9ab899368c307..a9ff2d59dc4e3 100644
--- a/server/src/main/java/org/elasticsearch/index/mapper/IndexFieldMapper.java
+++ b/server/src/main/java/org/elasticsearch/index/mapper/IndexFieldMapper.java
@@ -80,7 +80,8 @@ public IndexFieldMapper build(BuilderContext context) {
public static class TypeParser implements MetadataFieldMapper.TypeParser {
@Override
- public MetadataFieldMapper.Builder,?> parse(String name, Map node, ParserContext parserContext) throws MapperParsingException {
+ public MetadataFieldMapper.Builder,?> parse(String name, Map node,
+ ParserContext parserContext) throws MapperParsingException {
if (parserContext.indexVersionCreated().onOrAfter(Version.V_5_0_0_alpha3)) {
throw new MapperParsingException(NAME + " is not configurable");
}
@@ -135,7 +136,8 @@ public Query termQuery(Object value, @Nullable QueryShardContext context) {
if (isSameIndex(value, context.getFullyQualifiedIndex().getName())) {
return Queries.newMatchAllQuery();
} else {
- return Queries.newMatchNoDocsQuery("Index didn't match. Index queried: " + context.index().getName() + " vs. " + value);
+ return Queries.newMatchNoDocsQuery("Index didn't match. Index queried: " + context.index().getName()
+ + " vs. " + value);
}
}
diff --git a/server/src/main/java/org/elasticsearch/index/mapper/MappedFieldType.java b/server/src/main/java/org/elasticsearch/index/mapper/MappedFieldType.java
index 6ba0b1be07f84..cceff797520fd 100644
--- a/server/src/main/java/org/elasticsearch/index/mapper/MappedFieldType.java
+++ b/server/src/main/java/org/elasticsearch/index/mapper/MappedFieldType.java
@@ -139,9 +139,11 @@ public int hashCode() {
/** Checks this type is the same type as other. Adds a conflict if they are different. */
private void checkTypeName(MappedFieldType other) {
if (typeName().equals(other.typeName()) == false) {
- throw new IllegalArgumentException("mapper [" + name + "] cannot be changed from type [" + typeName() + "] to [" + other.typeName() + "]");
+ throw new IllegalArgumentException("mapper [" + name + "] cannot be changed from type [" + typeName()
+ + "] to [" + other.typeName() + "]");
} else if (getClass() != other.getClass()) {
- throw new IllegalStateException("Type names equal for class " + getClass().getSimpleName() + " and " + other.getClass().getSimpleName());
+ throw new IllegalStateException("Type names equal for class " + getClass().getSimpleName() + " and "
+ + other.getClass().getSimpleName());
}
}
@@ -198,22 +200,28 @@ public void checkCompatibility(MappedFieldType other, List conflicts, bo
if (strict) {
if (omitNorms() != other.omitNorms()) {
- conflicts.add("mapper [" + name() + "] is used by multiple types. Set update_all_types to true to update [omit_norms] across all types.");
+ conflicts.add("mapper [" + name() + "] is used by multiple types. Set update_all_types to true to update"
+ + " [omit_norms] across all types.");
}
if (boost() != other.boost()) {
- conflicts.add("mapper [" + name() + "] is used by multiple types. Set update_all_types to true to update [boost] across all types.");
+ conflicts.add("mapper [" + name() + "] is used by multiple types. Set update_all_types to true to update"
+ + " [boost] across all types.");
}
if (Objects.equals(searchAnalyzer(), other.searchAnalyzer()) == false) {
- conflicts.add("mapper [" + name() + "] is used by multiple types. Set update_all_types to true to update [search_analyzer] across all types.");
+ conflicts.add("mapper [" + name() + "] is used by multiple types. Set update_all_types to true to update"
+ + " [search_analyzer] across all types.");
}
if (Objects.equals(searchQuoteAnalyzer(), other.searchQuoteAnalyzer()) == false) {
- conflicts.add("mapper [" + name() + "] is used by multiple types. Set update_all_types to true to update [search_quote_analyzer] across all types.");
+ conflicts.add("mapper [" + name() + "] is used by multiple types. Set update_all_types to true to update"
+ + " [search_quote_analyzer] across all types.");
}
if (Objects.equals(nullValue(), other.nullValue()) == false) {
- conflicts.add("mapper [" + name() + "] is used by multiple types. Set update_all_types to true to update [null_value] across all types.");
+ conflicts.add("mapper [" + name() + "] is used by multiple types. Set update_all_types to true to update"
+ + " [null_value] across all types.");
}
if (eagerGlobalOrdinals() != other.eagerGlobalOrdinals()) {
- conflicts.add("mapper [" + name() + "] is used by multiple types. Set update_all_types to true to update [eager_global_ordinals] across all types.");
+ conflicts.add("mapper [" + name() + "] is used by multiple types. Set update_all_types to true to update"
+ + " [eager_global_ordinals] across all types.");
}
}
}
@@ -360,21 +368,26 @@ public Query rangeQuery(
}
public Query fuzzyQuery(Object value, Fuzziness fuzziness, int prefixLength, int maxExpansions, boolean transpositions) {
- throw new IllegalArgumentException("Can only use fuzzy queries on keyword and text fields - not on [" + name + "] which is of type [" + typeName() + "]");
+ throw new IllegalArgumentException("Can only use fuzzy queries on keyword and text fields - not on [" + name
+ + "] which is of type [" + typeName() + "]");
}
public Query prefixQuery(String value, @Nullable MultiTermQuery.RewriteMethod method, QueryShardContext context) {
- throw new QueryShardException(context, "Can only use prefix queries on keyword and text fields - not on [" + name + "] which is of type [" + typeName() + "]");
+ throw new QueryShardException(context, "Can only use prefix queries on keyword and text fields - not on [" + name
+ + "] which is of type [" + typeName() + "]");
}
public Query wildcardQuery(String value,
@Nullable MultiTermQuery.RewriteMethod method,
QueryShardContext context) {
- throw new QueryShardException(context, "Can only use wildcard queries on keyword and text fields - not on [" + name + "] which is of type [" + typeName() + "]");
+ throw new QueryShardException(context, "Can only use wildcard queries on keyword and text fields - not on [" + name
+ + "] which is of type [" + typeName() + "]");
}
- public Query regexpQuery(String value, int flags, int maxDeterminizedStates, @Nullable MultiTermQuery.RewriteMethod method, QueryShardContext context) {
- throw new QueryShardException(context, "Can only use regexp queries on keyword and text fields - not on [" + name + "] which is of type [" + typeName() + "]");
+ public Query regexpQuery(String value, int flags, int maxDeterminizedStates, @Nullable MultiTermQuery.RewriteMethod method,
+ QueryShardContext context) {
+ throw new QueryShardException(context, "Can only use regexp queries on keyword and text fields - not on [" + name
+ + "] which is of type [" + typeName() + "]");
}
public Query nullValueQuery() {
diff --git a/server/src/main/java/org/elasticsearch/index/mapper/MapperService.java b/server/src/main/java/org/elasticsearch/index/mapper/MapperService.java
index c8ecd0746f15a..fa3436655521a 100644
--- a/server/src/main/java/org/elasticsearch/index/mapper/MapperService.java
+++ b/server/src/main/java/org/elasticsearch/index/mapper/MapperService.java
@@ -158,7 +158,8 @@ public MapperService(IndexSettings indexSettings, IndexAnalyzers indexAnalyzers,
if (indexSettings.getIndexVersionCreated().onOrAfter(Version.V_6_0_0_rc1)) {
if (INDEX_MAPPER_DYNAMIC_SETTING.exists(indexSettings.getSettings())) {
- DEPRECATION_LOGGER.deprecated("Setting " + INDEX_MAPPER_DYNAMIC_SETTING.getKey() + " is deprecated since indices may not have more than one type anymore.");
+ DEPRECATION_LOGGER.deprecated("Setting " + INDEX_MAPPER_DYNAMIC_SETTING.getKey()
+ + " is deprecated since indices may not have more than one type anymore.");
}
this.dynamic = INDEX_MAPPER_DYNAMIC_DEFAULT;
} else {
@@ -196,7 +197,9 @@ public Iterable docMappers(final boolean includingDefaultMapping
if (includingDefaultMapping) {
documentMappers = mappers.values();
} else {
- documentMappers = mappers.values().stream().filter(mapper -> !DEFAULT_MAPPING.equals(mapper.type())).collect(Collectors.toList());
+ documentMappers = mappers.values().stream()
+ .filter(mapper -> !DEFAULT_MAPPING.equals(mapper.type()))
+ .collect(Collectors.toList());
}
return Collections.unmodifiableCollection(documentMappers).iterator();
};
@@ -228,7 +231,8 @@ public static Map parseMapping(NamedXContentRegistry xContentReg
* Update mapping by only merging the metadata that is different between received and stored entries
*/
public boolean updateMapping(final IndexMetaData currentIndexMetaData, final IndexMetaData newIndexMetaData) throws IOException {
- assert newIndexMetaData.getIndex().equals(index()) : "index mismatch: expected " + index() + " but was " + newIndexMetaData.getIndex();
+ assert newIndexMetaData.getIndex().equals(index()) : "index mismatch: expected " + index()
+ + " but was " + newIndexMetaData.getIndex();
// go over and add the relevant mappings (or update them)
final Set existingMappers = new HashSet<>(mappers.keySet());
final Map updatedEntries;
@@ -254,15 +258,16 @@ public boolean updateMapping(final IndexMetaData currentIndexMetaData, final Ind
} else if (logger.isTraceEnabled()) {
logger.trace("[{}] {} mapping [{}], source [{}]", index(), op, mappingType, incomingMappingSource.string());
} else {
- logger.debug("[{}] {} mapping [{}] (source suppressed due to length, use TRACE level if needed)", index(), op, mappingType);
+ logger.debug("[{}] {} mapping [{}] (source suppressed due to length, use TRACE level if needed)",
+ index(), op, mappingType);
}
// refresh mapping can happen when the parsing/merging of the mapping from the metadata doesn't result in the same
// mapping, in this case, we send to the master to refresh its own version of the mappings (to conform with the
// merge version of it, which it does when refreshing the mappings), and warn log it.
if (documentMapper(mappingType).mappingSource().equals(incomingMappingSource) == false) {
- logger.debug("[{}] parsed mapping [{}], and got different sources\noriginal:\n{}\nparsed:\n{}", index(), mappingType,
- incomingMappingSource, documentMapper(mappingType).mappingSource());
+ logger.debug("[{}] parsed mapping [{}], and got different sources\noriginal:\n{}\nparsed:\n{}",
+ index(), mappingType, incomingMappingSource, documentMapper(mappingType).mappingSource());
requireRefresh = true;
}
@@ -314,7 +319,8 @@ public void merge(Map> mappings, MergeReason reason,
Map mappingSourcesCompressed = new LinkedHashMap<>(mappings.size());
for (Map.Entry> entry : mappings.entrySet()) {
try {
- mappingSourcesCompressed.put(entry.getKey(), new CompressedXContent(Strings.toString(XContentFactory.jsonBuilder().map(entry.getValue()))));
+ mappingSourcesCompressed.put(entry.getKey(), new CompressedXContent(Strings.toString(
+ XContentFactory.jsonBuilder().map(entry.getValue()))));
} catch (Exception e) {
throw new MapperParsingException("Failed to parse mapping [{}]: {}", e, entry.getKey(), e.getMessage());
}
@@ -331,8 +337,8 @@ public DocumentMapper merge(String type, CompressedXContent mappingSource, Merge
return internalMerge(Collections.singletonMap(type, mappingSource), reason, updateAllTypes).get(type);
}
- private synchronized Map internalMerge(IndexMetaData indexMetaData, MergeReason reason, boolean updateAllTypes,
- boolean onlyUpdateIfNeeded) {
+ private synchronized Map internalMerge(IndexMetaData indexMetaData, MergeReason reason,
+ boolean updateAllTypes, boolean onlyUpdateIfNeeded) {
Map map = new LinkedHashMap<>();
for (ObjectCursor cursor : indexMetaData.getMappings().values()) {
MappingMetaData mappingMetaData = cursor.value;
@@ -348,7 +354,8 @@ private synchronized Map internalMerge(IndexMetaData ind
return internalMerge(map, reason, updateAllTypes);
}
- private synchronized Map internalMerge(Map mappings, MergeReason reason, boolean updateAllTypes) {
+ private synchronized Map internalMerge(Map mappings,
+ MergeReason reason, boolean updateAllTypes) {
DocumentMapper defaultMapper = null;
String defaultMappingSource = null;
@@ -404,10 +411,12 @@ static void validateTypeName(String type) {
throw new InvalidTypeNameException("mapping type name is empty");
}
if (type.length() > 255) {
- throw new InvalidTypeNameException("mapping type name [" + type + "] is too long; limit is length 255 but was [" + type.length() + "]");
+ throw new InvalidTypeNameException("mapping type name [" + type + "] is too long; limit is length 255 but was ["
+ + type.length() + "]");
}
if (type.charAt(0) == '_' && SINGLE_MAPPING_NAME.equals(type) == false) {
- throw new InvalidTypeNameException("mapping type name [" + type + "] can't start with '_' unless it is called [" + SINGLE_MAPPING_NAME + "]");
+ throw new InvalidTypeNameException("mapping type name [" + type + "] can't start with '_' unless it is called ["
+ + SINGLE_MAPPING_NAME + "]");
}
if (type.contains("#")) {
throw new InvalidTypeNameException("mapping type name [" + type + "] should not include '#' in it");
@@ -420,8 +429,10 @@ static void validateTypeName(String type) {
}
}
- private synchronized Map internalMerge(@Nullable DocumentMapper defaultMapper, @Nullable String defaultMappingSource,
- List documentMappers, MergeReason reason, boolean updateAllTypes) {
+ private synchronized Map internalMerge(@Nullable DocumentMapper defaultMapper,
+ @Nullable String defaultMappingSource,
+ List documentMappers,
+ MergeReason reason, boolean updateAllTypes) {
boolean hasNested = this.hasNested;
boolean allEnabled = this.allEnabled;
Map fullPathObjectMappers = this.fullPathObjectMappers;
@@ -448,7 +459,8 @@ private synchronized Map internalMerge(@Nullable Documen
actualTypes.remove(DEFAULT_MAPPING);
if (actualTypes.size() > 1) {
throw new IllegalArgumentException(
- "Rejecting mapping update to [" + index().getName() + "] as the final mapping would have more than 1 type: " + actualTypes);
+ "Rejecting mapping update to [" + index().getName() + "] as the final mapping would have more than 1 type: "
+ + actualTypes);
}
}
@@ -508,7 +520,8 @@ private synchronized Map internalMerge(@Nullable Documen
// deserializing cluster state that was sent by the master node,
// this check will be skipped.
// Also, don't take metadata mappers into account for the field limit check
- checkTotalFieldsLimit(objectMappers.size() + fieldMappers.size() - metadataMappers.length + fieldAliasMappers.size() );
+ checkTotalFieldsLimit(objectMappers.size() + fieldMappers.size() - metadataMappers.length
+ + fieldAliasMappers.size() );
}
if (oldMapper == null && newMapper.parentFieldMapper().active()) {
@@ -618,14 +631,16 @@ private void checkNestedFieldsLimit(Map fullPathObjectMapp
}
}
if (actualNestedFields > allowedNestedFields) {
- throw new IllegalArgumentException("Limit of nested fields [" + allowedNestedFields + "] in index [" + index().getName() + "] has been exceeded");
+ throw new IllegalArgumentException("Limit of nested fields [" + allowedNestedFields + "] in index [" + index().getName()
+ + "] has been exceeded");
}
}
private void checkTotalFieldsLimit(long totalMappers) {
long allowedTotalFields = indexSettings.getValue(INDEX_MAPPING_TOTAL_FIELDS_LIMIT_SETTING);
if (allowedTotalFields < totalMappers) {
- throw new IllegalArgumentException("Limit of total fields [" + allowedTotalFields + "] in index [" + index().getName() + "] has been exceeded");
+ throw new IllegalArgumentException("Limit of total fields [" + allowedTotalFields + "] in index [" + index().getName()
+ + "] has been exceeded");
}
}
diff --git a/server/src/main/java/org/elasticsearch/index/mapper/Mapping.java b/server/src/main/java/org/elasticsearch/index/mapper/Mapping.java
index 0ca2b2ea94447..7f59d4e623871 100644
--- a/server/src/main/java/org/elasticsearch/index/mapper/Mapping.java
+++ b/server/src/main/java/org/elasticsearch/index/mapper/Mapping.java
@@ -48,7 +48,8 @@ public final class Mapping implements ToXContentFragment {
final Map, MetadataFieldMapper> metadataMappersMap;
final Map meta;
- public Mapping(Version indexCreated, RootObjectMapper rootObjectMapper, MetadataFieldMapper[] metadataMappers, Map meta) {
+ public Mapping(Version indexCreated, RootObjectMapper rootObjectMapper,
+ MetadataFieldMapper[] metadataMappers, Map meta) {
this.indexCreated = indexCreated;
this.metadataMappers = metadataMappers;
Map, MetadataFieldMapper> metadataMappersMap = new HashMap<>();
diff --git a/server/src/main/java/org/elasticsearch/index/mapper/MetadataFieldMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/MetadataFieldMapper.java
index 4e456cdc994ff..5b26b1a37bf7c 100644
--- a/server/src/main/java/org/elasticsearch/index/mapper/MetadataFieldMapper.java
+++ b/server/src/main/java/org/elasticsearch/index/mapper/MetadataFieldMapper.java
@@ -33,7 +33,8 @@ public abstract class MetadataFieldMapper extends FieldMapper {
public interface TypeParser extends Mapper.TypeParser {
@Override
- MetadataFieldMapper.Builder,?> parse(String name, Map node, ParserContext parserContext) throws MapperParsingException;
+ MetadataFieldMapper.Builder,?> parse(String name, Map node,
+ ParserContext parserContext) throws MapperParsingException;
/**
* Get the default {@link MetadataFieldMapper} to use, if nothing had to be parsed.
diff --git a/server/src/main/java/org/elasticsearch/index/mapper/ObjectMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/ObjectMapper.java
index 4fa8623183931..13871fcb8927e 100644
--- a/server/src/main/java/org/elasticsearch/index/mapper/ObjectMapper.java
+++ b/server/src/main/java/org/elasticsearch/index/mapper/ObjectMapper.java
@@ -177,7 +177,8 @@ public Mapper.Builder parse(String name, Map node, ParserContext
return builder;
}
- protected static boolean parseObjectOrDocumentTypeProperties(String fieldName, Object fieldNode, ParserContext parserContext, ObjectMapper.Builder builder) {
+ protected static boolean parseObjectOrDocumentTypeProperties(String fieldName, Object fieldNode, ParserContext parserContext,
+ ObjectMapper.Builder builder) {
if (fieldName.equals("dynamic")) {
String value = fieldNode.toString();
if (value.equalsIgnoreCase("strict")) {
@@ -219,7 +220,8 @@ protected static void parseNested(String name, Map node, ObjectM
} else if (type.equals(NESTED_CONTENT_TYPE)) {
nested = true;
} else {
- throw new MapperParsingException("Trying to parse an object but has a different type [" + type + "] for [" + name + "]");
+ throw new MapperParsingException("Trying to parse an object but has a different type [" + type
+ + "] for [" + name + "]");
}
}
fieldNode = node.get("include_in_parent");
@@ -447,7 +449,8 @@ public boolean parentObjectMapperAreNested(MapperService mapperService) {
@Override
public ObjectMapper merge(Mapper mergeWith, boolean updateAllTypes) {
if (!(mergeWith instanceof ObjectMapper)) {
- throw new IllegalArgumentException("Can't merge a non object mapping [" + mergeWith.name() + "] with an object mapping [" + name() + "]");
+ throw new IllegalArgumentException("Can't merge a non object mapping [" + mergeWith.name()
+ + "] with an object mapping [" + name() + "]");
}
ObjectMapper mergeWithObject = (ObjectMapper) mergeWith;
ObjectMapper merged = clone();
@@ -537,7 +540,8 @@ public void toXContent(XContentBuilder builder, Params params, ToXContent custom
if (nested.isIncludeInRoot()) {
builder.field("include_in_root", true);
}
- } else if (mappers.isEmpty() && custom == null) { // only write the object content type if there are no properties, otherwise, it is automatically detected
+ } else if (mappers.isEmpty() && custom == null) {
+ // only write the object content type if there are no properties, otherwise, it is automatically detected
builder.field("type", CONTENT_TYPE);
}
if (dynamic != null) {
diff --git a/server/src/main/java/org/elasticsearch/index/mapper/ParentFieldMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/ParentFieldMapper.java
index 8cd049f1f5a48..4056c9556c45b 100644
--- a/server/src/main/java/org/elasticsearch/index/mapper/ParentFieldMapper.java
+++ b/server/src/main/java/org/elasticsearch/index/mapper/ParentFieldMapper.java
@@ -106,14 +106,16 @@ public ParentFieldMapper build(BuilderContext context) {
}
name = joinField(parentType);
setupFieldType(context);
- return new ParentFieldMapper(createParentJoinFieldMapper(documentType, context), fieldType, parentType, context.indexSettings());
+ return new ParentFieldMapper(createParentJoinFieldMapper(documentType, context), fieldType,
+ parentType, context.indexSettings());
}
}
public static class TypeParser implements MetadataFieldMapper.TypeParser {
private static final ParseField FIELDDATA = new ParseField("fielddata").withAllDeprecated("eager_global_ordinals");
@Override
- public MetadataFieldMapper.Builder parse(String name, Map node, ParserContext parserContext) throws MapperParsingException {
+ public MetadataFieldMapper.Builder parse(String name, Map node,
+ ParserContext parserContext) throws MapperParsingException {
Builder builder = new Builder(parserContext.type());
for (Iterator> iterator = node.entrySet().iterator(); iterator.hasNext();) {
Map.Entry entry = iterator.next();
@@ -141,7 +143,8 @@ public MetadataFieldMapper.Builder parse(String name, Map node,
public MetadataFieldMapper getDefault(MappedFieldType fieldType, ParserContext context) {
final Settings indexSettings = context.mapperService().getIndexSettings().getSettings();
final String typeName = context.type();
- KeywordFieldMapper parentJoinField = createParentJoinFieldMapper(typeName, new BuilderContext(indexSettings, new ContentPath(0)));
+ KeywordFieldMapper parentJoinField = createParentJoinFieldMapper(typeName,
+ new BuilderContext(indexSettings, new ContentPath(0)));
MappedFieldType childJoinFieldType = new ParentFieldType(Defaults.FIELD_TYPE, typeName);
childJoinFieldType.setName(ParentFieldMapper.NAME);
return new ParentFieldMapper(parentJoinField, childJoinFieldType, null, indexSettings);
@@ -218,7 +221,8 @@ public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) {
// the parent field mapper in the child type pointing to this type determines the field data settings for this join field
private final KeywordFieldMapper parentJoinField;
- private ParentFieldMapper(KeywordFieldMapper parentJoinField, MappedFieldType childJoinFieldType, String parentType, Settings indexSettings) {
+ private ParentFieldMapper(KeywordFieldMapper parentJoinField, MappedFieldType childJoinFieldType,
+ String parentType, Settings indexSettings) {
super(NAME, childJoinFieldType, Defaults.FIELD_TYPE, indexSettings);
this.parentType = parentType;
this.parentJoinField = parentJoinField;
@@ -269,7 +273,8 @@ protected void parseCreateField(ParseContext context, List field
// we did not add it in the parsing phase, add it now
fields.add(new SortedDocValuesField(fieldType.name(), new BytesRef(parentId)));
} else if (parentId != null && !parsedParentId.equals(Uid.createUid(parentType, parentId))) {
- throw new MapperParsingException("Parent id mismatch, document value is [" + Uid.createUid(parsedParentId).id() + "], while external value is [" + parentId + "]");
+ throw new MapperParsingException("Parent id mismatch, document value is [" + Uid.createUid(parsedParentId).id()
+ + "], while external value is [" + parentId + "]");
}
}
}
@@ -310,7 +315,8 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
protected void doMerge(Mapper mergeWith, boolean updateAllTypes) {
ParentFieldMapper fieldMergeWith = (ParentFieldMapper) mergeWith;
if (fieldMergeWith.parentType != null && Objects.equals(parentType, fieldMergeWith.parentType) == false) {
- throw new IllegalArgumentException("The _parent field's type option can't be changed: [" + parentType + "]->[" + fieldMergeWith.parentType + "]");
+ throw new IllegalArgumentException("The _parent field's type option can't be changed: [" + parentType + "]->["
+ + fieldMergeWith.parentType + "]");
}
// If fieldMergeWith is not active it means the user provided a mapping
// update that does not explicitly configure the _parent field, so we
diff --git a/server/src/main/java/org/elasticsearch/index/mapper/RootObjectMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/RootObjectMapper.java
index 2e2898d781fb5..0d281d0f0a5fe 100644
--- a/server/src/main/java/org/elasticsearch/index/mapper/RootObjectMapper.java
+++ b/server/src/main/java/org/elasticsearch/index/mapper/RootObjectMapper.java
@@ -55,7 +55,8 @@ public static class Defaults {
public static class Builder extends ObjectMapper.Builder {
protected Explicit dynamicTemplates = new Explicit<>(new DynamicTemplate[0], false);
- protected Explicit dynamicDateTimeFormatters = new Explicit<>(Defaults.DYNAMIC_DATE_TIME_FORMATTERS, false);
+ protected Explicit dynamicDateTimeFormatters =
+ new Explicit<>(Defaults.DYNAMIC_DATE_TIME_FORMATTERS, false);
protected Explicit dateDetection = new Explicit<>(Defaults.DATE_DETECTION, false);
protected Explicit numericDetection = new Explicit<>(Defaults.NUMERIC_DETECTION, false);
diff --git a/server/src/main/java/org/elasticsearch/index/mapper/RoutingFieldMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/RoutingFieldMapper.java
index 52f55699eb317..b23d1daeabdab 100644
--- a/server/src/main/java/org/elasticsearch/index/mapper/RoutingFieldMapper.java
+++ b/server/src/main/java/org/elasticsearch/index/mapper/RoutingFieldMapper.java
@@ -81,7 +81,8 @@ public RoutingFieldMapper build(BuilderContext context) {
public static class TypeParser implements MetadataFieldMapper.TypeParser {
@Override
- public MetadataFieldMapper.Builder,?> parse(String name, Map node, ParserContext parserContext) throws MapperParsingException {
+ public MetadataFieldMapper.Builder,?> parse(String name, Map node,
+ ParserContext parserContext) throws MapperParsingException {
Builder builder = new Builder(parserContext.mapperService().fullName(NAME));
for (Iterator> iterator = node.entrySet().iterator(); iterator.hasNext();) {
Map.Entry entry = iterator.next();
diff --git a/server/src/main/java/org/elasticsearch/index/mapper/SourceFieldMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/SourceFieldMapper.java
index cf45d37392744..f66dde9156d94 100644
--- a/server/src/main/java/org/elasticsearch/index/mapper/SourceFieldMapper.java
+++ b/server/src/main/java/org/elasticsearch/index/mapper/SourceFieldMapper.java
@@ -108,7 +108,8 @@ public SourceFieldMapper build(BuilderContext context) {
public static class TypeParser implements MetadataFieldMapper.TypeParser {
@Override
- public MetadataFieldMapper.Builder,?> parse(String name, Map node, ParserContext parserContext) throws MapperParsingException {
+ public MetadataFieldMapper.Builder,?> parse(String name, Map node,
+ ParserContext parserContext) throws MapperParsingException {
Builder builder = new Builder();
for (Iterator> iterator = node.entrySet().iterator(); iterator.hasNext();) {
diff --git a/server/src/main/java/org/elasticsearch/index/mapper/TypeFieldMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/TypeFieldMapper.java
index 5bd831d1a8b44..75be214dc5c4d 100644
--- a/server/src/main/java/org/elasticsearch/index/mapper/TypeFieldMapper.java
+++ b/server/src/main/java/org/elasticsearch/index/mapper/TypeFieldMapper.java
@@ -81,7 +81,8 @@ public static class Defaults {
public static class TypeParser implements MetadataFieldMapper.TypeParser {
@Override
- public MetadataFieldMapper.Builder,?> parse(String name, Map node, ParserContext parserContext) throws MapperParsingException {
+ public MetadataFieldMapper.Builder,?> parse(String name, Map node,
+ ParserContext parserContext) throws MapperParsingException {
throw new MapperParsingException(NAME + " is not configurable");
}
@@ -187,7 +188,8 @@ public Query rangeQuery(Object lowerTerm, Object upperTerm, boolean includeLower
} else {
// this means the index has a single type and the type field is implicit
DEPRECATION_LOGGER.deprecatedAndMaybeLog("range_single_type",
- "Running [range] query on [_type] field for an index with a single type. As types are deprecated, this functionality will be removed in future releases.");
+ "Running [range] query on [_type] field for an index with a single type. As types are deprecated,"
+ + " this functionality will be removed in future releases.");
Collection types = context.getMapperService().types();
String type = types.iterator().hasNext() ? types.iterator().next() : null;
if (type != null) {
diff --git a/server/src/main/java/org/elasticsearch/index/mapper/UidFieldMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/UidFieldMapper.java
index 43fee345ffa33..cb6ec550cff89 100644
--- a/server/src/main/java/org/elasticsearch/index/mapper/UidFieldMapper.java
+++ b/server/src/main/java/org/elasticsearch/index/mapper/UidFieldMapper.java
@@ -80,7 +80,8 @@ public static class Defaults {
public static class TypeParser implements MetadataFieldMapper.TypeParser {
@Override
- public MetadataFieldMapper.Builder, ?> parse(String name, Map node, ParserContext parserContext) throws MapperParsingException {
+ public MetadataFieldMapper.Builder, ?> parse(String name, Map node,
+ ParserContext parserContext) throws MapperParsingException {
throw new MapperParsingException(NAME + " is not configurable");
}
diff --git a/server/src/main/java/org/elasticsearch/index/mapper/VersionFieldMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/VersionFieldMapper.java
index 9b33c5c84f714..a98224c76e06b 100644
--- a/server/src/main/java/org/elasticsearch/index/mapper/VersionFieldMapper.java
+++ b/server/src/main/java/org/elasticsearch/index/mapper/VersionFieldMapper.java
@@ -58,7 +58,8 @@ public static class Defaults {
public static class TypeParser implements MetadataFieldMapper.TypeParser {
@Override
- public MetadataFieldMapper.Builder, ?> parse(String name, Map node, ParserContext parserContext) throws MapperParsingException {
+ public MetadataFieldMapper.Builder, ?> parse(String name, Map node,
+ ParserContext parserContext) throws MapperParsingException {
throw new MapperParsingException(NAME + " is not configurable");
}
diff --git a/server/src/test/java/org/elasticsearch/index/mapper/CompletionFieldMapperTests.java b/server/src/test/java/org/elasticsearch/index/mapper/CompletionFieldMapperTests.java
index d8df9eedb88c2..8a6ce2b09274f 100644
--- a/server/src/test/java/org/elasticsearch/index/mapper/CompletionFieldMapperTests.java
+++ b/server/src/test/java/org/elasticsearch/index/mapper/CompletionFieldMapperTests.java
@@ -69,7 +69,8 @@ public void testDefaultConfiguration() throws IOException {
.endObject().endObject()
.endObject().endObject());
- DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser().parse("type1", new CompressedXContent(mapping));
+ DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("type1", new CompressedXContent(mapping));
Mapper fieldMapper = defaultMapper.mappers().getMapper("completion");
assertThat(fieldMapper, instanceOf(CompletionFieldMapper.class));
@@ -101,7 +102,8 @@ public void testCompletionAnalyzerSettings() throws Exception {
.endObject().endObject()
.endObject().endObject());
- DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser().parse("type1", new CompressedXContent(mapping));
+ DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("type1", new CompressedXContent(mapping));
Mapper fieldMapper = defaultMapper.mappers().getMapper("completion");
assertThat(fieldMapper, instanceOf(CompletionFieldMapper.class));
@@ -135,7 +137,8 @@ public void testTypeParsing() throws Exception {
.endObject().endObject()
.endObject().endObject());
- DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser().parse("type1", new CompressedXContent(mapping));
+ DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("type1", new CompressedXContent(mapping));
Mapper fieldMapper = defaultMapper.mappers().getMapper("completion");
assertThat(fieldMapper, instanceOf(CompletionFieldMapper.class));
@@ -159,11 +162,12 @@ public void testParsingMinimal() throws Exception {
.endObject().endObject()
.endObject().endObject());
- DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser().parse("type1", new CompressedXContent(mapping));
+ DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("type1", new CompressedXContent(mapping));
Mapper fieldMapper = defaultMapper.mappers().getMapper("completion");
- ParsedDocument parsedDocument = defaultMapper.parse(SourceToParse.source("test", "type1", "1", BytesReference
- .bytes(XContentFactory.jsonBuilder()
+ ParsedDocument parsedDocument = defaultMapper.parse(SourceToParse.source("test", "type1", "1",
+ BytesReference.bytes(XContentFactory.jsonBuilder()
.startObject()
.field("completion", "suggestion")
.endObject()),
@@ -179,11 +183,12 @@ public void testParsingFailure() throws Exception {
.endObject().endObject()
.endObject().endObject());
- DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser().parse("type1", new CompressedXContent(mapping));
+ DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("type1", new CompressedXContent(mapping));
MapperParsingException e = expectThrows(MapperParsingException.class, () ->
- defaultMapper.parse(SourceToParse.source("test", "type1", "1", BytesReference
- .bytes(XContentFactory.jsonBuilder()
+ defaultMapper.parse(SourceToParse.source("test", "type1", "1",
+ BytesReference.bytes(XContentFactory.jsonBuilder()
.startObject()
.field("completion", 1.0)
.endObject()),
@@ -212,10 +217,11 @@ public void testKeywordWithSubCompletionAndContext() throws Exception {
.endObject().endObject()
);
- DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser().parse("type1", new CompressedXContent(mapping));
+ DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("type1", new CompressedXContent(mapping));
- ParsedDocument parsedDocument = defaultMapper.parse(SourceToParse.source("test", "type1", "1", BytesReference
- .bytes(XContentFactory.jsonBuilder()
+ ParsedDocument parsedDocument = defaultMapper.parse(SourceToParse.source("test", "type1", "1",
+ BytesReference.bytes(XContentFactory.jsonBuilder()
.startObject()
.array("keywordfield", "key1", "key2", "key3")
.endObject()),
@@ -266,10 +272,11 @@ public void testCompletionWithContextAndSubCompletion() throws Exception {
.endObject().endObject()
);
- DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser().parse("type1", new CompressedXContent(mapping));
+ DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("type1", new CompressedXContent(mapping));
- ParsedDocument parsedDocument = defaultMapper.parse(SourceToParse.source("test", "type1", "1", BytesReference
- .bytes(XContentFactory.jsonBuilder()
+ ParsedDocument parsedDocument = defaultMapper.parse(SourceToParse.source("test", "type1", "1",
+ BytesReference.bytes(XContentFactory.jsonBuilder()
.startObject()
.startObject("suggest")
.array("input","timmy","starbucks")
@@ -321,10 +328,11 @@ public void testCompletionWithContextAndSubCompletionIndexByPath() throws Except
.endObject().endObject()
);
- DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser().parse("type1", new CompressedXContent(mapping));
+ DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("type1", new CompressedXContent(mapping));
- ParsedDocument parsedDocument = defaultMapper.parse(SourceToParse.source("test", "type1", "1", BytesReference
- .bytes(XContentFactory.jsonBuilder()
+ ParsedDocument parsedDocument = defaultMapper.parse(SourceToParse.source("test", "type1", "1",
+ BytesReference.bytes(XContentFactory.jsonBuilder()
.startObject()
.array("suggest", "timmy","starbucks")
.array("cat","cafe","food")
@@ -357,10 +365,11 @@ public void testKeywordWithSubCompletionAndStringInsert() throws Exception {
.endObject().endObject()
);
- DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser().parse("type1", new CompressedXContent(mapping));
+ DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("type1", new CompressedXContent(mapping));
- ParsedDocument parsedDocument = defaultMapper.parse(SourceToParse.source("test", "type1", "1", BytesReference
- .bytes(XContentFactory.jsonBuilder()
+ ParsedDocument parsedDocument = defaultMapper.parse(SourceToParse.source("test", "type1", "1",
+ BytesReference.bytes(XContentFactory.jsonBuilder()
.startObject()
.field("geofield", "drm3btev3e86")//"41.12,-71.34"
.endObject()),
@@ -387,10 +396,11 @@ public void testCompletionTypeWithSubCompletionFieldAndStringInsert() throws Exc
.endObject().endObject()
);
- DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser().parse("type1", new CompressedXContent(mapping));
+ DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("type1", new CompressedXContent(mapping));
- ParsedDocument parsedDocument = defaultMapper.parse(SourceToParse.source("test", "type1", "1", BytesReference
- .bytes(XContentFactory.jsonBuilder()
+ ParsedDocument parsedDocument = defaultMapper.parse(SourceToParse.source("test", "type1", "1",
+ BytesReference.bytes(XContentFactory.jsonBuilder()
.startObject()
.field("suggest", "suggestion")
.endObject()),
@@ -418,10 +428,11 @@ public void testCompletionTypeWithSubCompletionFieldAndObjectInsert() throws Exc
.endObject().endObject()
);
- DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser().parse("type1", new CompressedXContent(mapping));
+ DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("type1", new CompressedXContent(mapping));
- ParsedDocument parsedDocument = defaultMapper.parse(SourceToParse.source("test", "type1", "1", BytesReference
- .bytes(XContentFactory.jsonBuilder()
+ ParsedDocument parsedDocument = defaultMapper.parse(SourceToParse.source("test", "type1", "1",
+ BytesReference.bytes(XContentFactory.jsonBuilder()
.startObject()
.startObject("completion")
.array("input","New York", "NY")
@@ -455,10 +466,11 @@ public void testCompletionTypeWithSubKeywordFieldAndObjectInsert() throws Except
.endObject().endObject()
);
- DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser().parse("type1", new CompressedXContent(mapping));
+ DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("type1", new CompressedXContent(mapping));
- ParsedDocument parsedDocument = defaultMapper.parse(SourceToParse.source("test", "type1", "1", BytesReference
- .bytes(XContentFactory.jsonBuilder()
+ ParsedDocument parsedDocument = defaultMapper.parse(SourceToParse.source("test", "type1", "1",
+ BytesReference.bytes(XContentFactory.jsonBuilder()
.startObject()
.startObject("completion")
.array("input","New York", "NY")
@@ -494,10 +506,11 @@ public void testCompletionTypeWithSubKeywordFieldAndStringInsert() throws Except
.endObject().endObject()
);
- DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser().parse("type1", new CompressedXContent(mapping));
+ DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("type1", new CompressedXContent(mapping));
- ParsedDocument parsedDocument = defaultMapper.parse(SourceToParse.source("test", "type1", "1", BytesReference
- .bytes(XContentFactory.jsonBuilder()
+ ParsedDocument parsedDocument = defaultMapper.parse(SourceToParse.source("test", "type1", "1",
+ BytesReference.bytes(XContentFactory.jsonBuilder()
.startObject()
.field("completion", "suggestion")
.endObject()),
@@ -520,11 +533,12 @@ public void testParsingMultiValued() throws Exception {
.endObject().endObject()
.endObject().endObject());
- DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser().parse("type1", new CompressedXContent(mapping));
+ DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("type1", new CompressedXContent(mapping));
Mapper fieldMapper = defaultMapper.mappers().getMapper("completion");
- ParsedDocument parsedDocument = defaultMapper.parse(SourceToParse.source("test", "type1", "1", BytesReference
- .bytes(XContentFactory.jsonBuilder()
+ ParsedDocument parsedDocument = defaultMapper.parse(SourceToParse.source("test", "type1", "1",
+ BytesReference.bytes(XContentFactory.jsonBuilder()
.startObject()
.array("completion", "suggestion1", "suggestion2")
.endObject()),
@@ -543,11 +557,12 @@ public void testParsingWithWeight() throws Exception {
.endObject().endObject()
.endObject().endObject());
- DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser().parse("type1", new CompressedXContent(mapping));
+ DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("type1", new CompressedXContent(mapping));
Mapper fieldMapper = defaultMapper.mappers().getMapper("completion");
- ParsedDocument parsedDocument = defaultMapper.parse(SourceToParse.source("test", "type1", "1", BytesReference
- .bytes(XContentFactory.jsonBuilder()
+ ParsedDocument parsedDocument = defaultMapper.parse(SourceToParse.source("test", "type1", "1",
+ BytesReference.bytes(XContentFactory.jsonBuilder()
.startObject()
.startObject("completion")
.field("input", "suggestion")
@@ -568,11 +583,12 @@ public void testParsingMultiValueWithWeight() throws Exception {
.endObject().endObject()
.endObject().endObject());
- DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser().parse("type1", new CompressedXContent(mapping));
+ DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("type1", new CompressedXContent(mapping));
Mapper fieldMapper = defaultMapper.mappers().getMapper("completion");
- ParsedDocument parsedDocument = defaultMapper.parse(SourceToParse.source("test", "type1", "1", BytesReference
- .bytes(XContentFactory.jsonBuilder()
+ ParsedDocument parsedDocument = defaultMapper.parse(SourceToParse.source("test", "type1", "1",
+ BytesReference.bytes(XContentFactory.jsonBuilder()
.startObject()
.startObject("completion")
.array("input", "suggestion1", "suggestion2", "suggestion3")
@@ -635,11 +651,12 @@ public void testParsingFull() throws Exception {
.endObject().endObject()
.endObject().endObject());
- DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser().parse("type1", new CompressedXContent(mapping));
+ DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("type1", new CompressedXContent(mapping));
Mapper fieldMapper = defaultMapper.mappers().getMapper("completion");
- ParsedDocument parsedDocument = defaultMapper.parse(SourceToParse.source("test", "type1", "1", BytesReference
- .bytes(XContentFactory.jsonBuilder()
+ ParsedDocument parsedDocument = defaultMapper.parse(SourceToParse.source("test", "type1", "1",
+ BytesReference.bytes(XContentFactory.jsonBuilder()
.startObject()
.startArray("completion")
.startObject()
@@ -672,11 +689,12 @@ public void testParsingMixed() throws Exception {
.endObject().endObject()
.endObject().endObject());
- DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser().parse("type1", new CompressedXContent(mapping));
+ DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("type1", new CompressedXContent(mapping));
Mapper fieldMapper = defaultMapper.mappers().getMapper("completion");
- ParsedDocument parsedDocument = defaultMapper.parse(SourceToParse.source("test", "type1", "1", BytesReference
- .bytes(XContentFactory.jsonBuilder()
+ ParsedDocument parsedDocument = defaultMapper.parse(SourceToParse.source("test", "type1", "1",
+ BytesReference.bytes(XContentFactory.jsonBuilder()
.startObject()
.startArray("completion")
.startObject()
@@ -712,10 +730,11 @@ public void testNonContextEnabledParsingWithContexts() throws Exception {
.endObject().endObject()
.endObject().endObject());
- DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser().parse("type1", new CompressedXContent(mapping));
+ DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("type1", new CompressedXContent(mapping));
try {
- defaultMapper.parse(SourceToParse.source("test", "type1", "1", BytesReference
- .bytes(XContentFactory.jsonBuilder()
+ defaultMapper.parse(SourceToParse.source("test", "type1", "1",
+ BytesReference.bytes(XContentFactory.jsonBuilder()
.startObject()
.startObject("field1")
.field("input", "suggestion1")
@@ -739,13 +758,14 @@ public void testFieldValueValidation() throws Exception {
.endObject().endObject()
.endObject().endObject());
- DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser().parse("type1", new CompressedXContent(mapping));
+ DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("type1", new CompressedXContent(mapping));
CharsRefBuilder charsRefBuilder = new CharsRefBuilder();
charsRefBuilder.append("sugg");
charsRefBuilder.setCharAt(2, '\u001F');
try {
- defaultMapper.parse(SourceToParse.source("test", "type1", "1", BytesReference
- .bytes(XContentFactory.jsonBuilder()
+ defaultMapper.parse(SourceToParse.source("test", "type1", "1",
+ BytesReference.bytes(XContentFactory.jsonBuilder()
.startObject()
.field("completion", charsRefBuilder.get().toString())
.endObject()),
@@ -759,8 +779,8 @@ public void testFieldValueValidation() throws Exception {
charsRefBuilder.setCharAt(2, '\u0000');
try {
- defaultMapper.parse(SourceToParse.source("test", "type1", "1", BytesReference
- .bytes(XContentFactory.jsonBuilder()
+ defaultMapper.parse(SourceToParse.source("test", "type1", "1",
+ BytesReference.bytes(XContentFactory.jsonBuilder()
.startObject()
.field("completion", charsRefBuilder.get().toString())
.endObject()),
@@ -774,8 +794,8 @@ public void testFieldValueValidation() throws Exception {
charsRefBuilder.setCharAt(2, '\u001E');
try {
- defaultMapper.parse(SourceToParse.source("test", "type1", "1", BytesReference
- .bytes(XContentFactory.jsonBuilder()
+ defaultMapper.parse(SourceToParse.source("test", "type1", "1",
+ BytesReference.bytes(XContentFactory.jsonBuilder()
.startObject()
.field("completion", charsRefBuilder.get().toString())
.endObject()),
@@ -788,8 +808,8 @@ public void testFieldValueValidation() throws Exception {
}
// empty inputs are ignored
- ParsedDocument doc = defaultMapper.parse(SourceToParse.source("test", "type1", "1", BytesReference
- .bytes(XContentFactory.jsonBuilder()
+ ParsedDocument doc = defaultMapper.parse(SourceToParse.source("test", "type1", "1",
+ BytesReference.bytes(XContentFactory.jsonBuilder()
.startObject()
.array("completion", " ", "")
.endObject()),
@@ -801,8 +821,8 @@ public void testFieldValueValidation() throws Exception {
assertThat(ignoredFields.stringValue(), equalTo("completion"));
// null inputs are ignored
- ParsedDocument nullDoc = defaultMapper.parse(SourceToParse.source("test", "type1", "1", BytesReference
- .bytes(XContentFactory.jsonBuilder()
+ ParsedDocument nullDoc = defaultMapper.parse(SourceToParse.source("test", "type1", "1",
+ BytesReference.bytes(XContentFactory.jsonBuilder()
.startObject()
.nullField("completion")
.endObject()),
@@ -819,7 +839,8 @@ public void testPrefixQueryType() throws Exception {
.endObject().endObject()
.endObject().endObject());
- DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser().parse("type1", new CompressedXContent(mapping));
+ DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("type1", new CompressedXContent(mapping));
Mapper fieldMapper = defaultMapper.mappers().getMapper("completion");
CompletionFieldMapper completionFieldMapper = (CompletionFieldMapper) fieldMapper;
Query prefixQuery = completionFieldMapper.fieldType().prefixQuery(new BytesRef("co"));
@@ -833,7 +854,8 @@ public void testFuzzyQueryType() throws Exception {
.endObject().endObject()
.endObject().endObject());
- DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser().parse("type1", new CompressedXContent(mapping));
+ DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("type1", new CompressedXContent(mapping));
Mapper fieldMapper = defaultMapper.mappers().getMapper("completion");
CompletionFieldMapper completionFieldMapper = (CompletionFieldMapper) fieldMapper;
Query prefixQuery = completionFieldMapper.fieldType().fuzzyQuery("co",
@@ -850,7 +872,8 @@ public void testRegexQueryType() throws Exception {
.endObject().endObject()
.endObject().endObject());
- DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser().parse("type1", new CompressedXContent(mapping));
+ DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("type1", new CompressedXContent(mapping));
Mapper fieldMapper = defaultMapper.mappers().getMapper("completion");
CompletionFieldMapper completionFieldMapper = (CompletionFieldMapper) fieldMapper;
Query prefixQuery = completionFieldMapper.fieldType()
diff --git a/server/src/test/java/org/elasticsearch/index/mapper/CompletionFieldTypeTests.java b/server/src/test/java/org/elasticsearch/index/mapper/CompletionFieldTypeTests.java
index 587ac2e0605cc..1386d2e29a0fd 100644
--- a/server/src/test/java/org/elasticsearch/index/mapper/CompletionFieldTypeTests.java
+++ b/server/src/test/java/org/elasticsearch/index/mapper/CompletionFieldTypeTests.java
@@ -18,8 +18,6 @@
*/
package org.elasticsearch.index.mapper;
-import org.elasticsearch.index.mapper.CompletionFieldMapper;
-import org.elasticsearch.index.mapper.MappedFieldType;
import org.elasticsearch.search.suggest.completion.context.ContextBuilder;
import org.elasticsearch.search.suggest.completion.context.ContextMappings;
import org.junit.Before;
@@ -52,7 +50,8 @@ public void modify(MappedFieldType ft) {
@Override
public void modify(MappedFieldType ft) {
CompletionFieldMapper.CompletionFieldType cft = (CompletionFieldMapper.CompletionFieldType)ft;
- ContextMappings contextMappings = new ContextMappings(Arrays.asList(ContextBuilder.category("foo").build(), ContextBuilder.geo("geo").build()));
+ ContextMappings contextMappings = new ContextMappings(Arrays.asList(ContextBuilder.category("foo").build(),
+ ContextBuilder.geo("geo").build()));
cft.setContextMappings(contextMappings);
}
});
diff --git a/server/src/test/java/org/elasticsearch/index/mapper/CopyToMapperTests.java b/server/src/test/java/org/elasticsearch/index/mapper/CopyToMapperTests.java
index a59dceacfedc9..4ae19af147a88 100644
--- a/server/src/test/java/org/elasticsearch/index/mapper/CopyToMapperTests.java
+++ b/server/src/test/java/org/elasticsearch/index/mapper/CopyToMapperTests.java
@@ -145,7 +145,8 @@ public void testCopyToFieldsInnerObjectParsing() throws Exception {
.endObject().endObject().endObject());
- DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser().parse("type1", new CompressedXContent(mapping));
+ DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("type1", new CompressedXContent(mapping));
BytesReference json = BytesReference.bytes(jsonBuilder().startObject()
.field("copy_test", "foo")
@@ -172,7 +173,8 @@ public void testCopyToDynamicInnerObjectParsing() throws Exception {
.endObject()
.endObject().endObject());
- DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser().parse("type1", new CompressedXContent(mapping));
+ DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("type1", new CompressedXContent(mapping));
BytesReference json = BytesReference.bytes(jsonBuilder().startObject()
.field("copy_test", "foo")
@@ -209,7 +211,8 @@ public void testCopyToDynamicInnerInnerObjectParsing() throws Exception {
.endObject()
.endObject().endObject());
- DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser().parse("type1", new CompressedXContent(mapping));
+ DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("type1", new CompressedXContent(mapping));
BytesReference json = BytesReference.bytes(jsonBuilder().startObject()
.field("copy_test", "foo")
@@ -239,7 +242,8 @@ public void testCopyToStrictDynamicInnerObjectParsing() throws Exception {
.endObject()
.endObject().endObject());
- DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser().parse("type1", new CompressedXContent(mapping));
+ DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("type1", new CompressedXContent(mapping));
BytesReference json = BytesReference.bytes(jsonBuilder().startObject()
.field("copy_test", "foo")
@@ -273,7 +277,8 @@ public void testCopyToInnerStrictDynamicInnerObjectParsing() throws Exception {
.endObject()
.endObject().endObject());
- DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser().parse("type1", new CompressedXContent(mapping));
+ DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("type1", new CompressedXContent(mapping));
BytesReference json = BytesReference.bytes(jsonBuilder().startObject()
.field("copy_test", "foo")
@@ -283,7 +288,8 @@ public void testCopyToInnerStrictDynamicInnerObjectParsing() throws Exception {
docMapper.parse(SourceToParse.source("test", "type1", "1", json, XContentType.JSON)).rootDoc();
fail();
} catch (MapperParsingException ex) {
- assertThat(ex.getMessage(), startsWith("mapping set to strict, dynamic introduction of [field] within [very.far] is not allowed"));
+ assertThat(ex.getMessage(),
+ startsWith("mapping set to strict, dynamic introduction of [field] within [very.far] is not allowed"));
}
}
@@ -307,12 +313,14 @@ public void testCopyToFieldMerge() throws Exception {
.endObject().endObject().endObject());
MapperService mapperService = createIndex("test").mapperService();
- DocumentMapper docMapperBefore = mapperService.merge("type1", new CompressedXContent(mappingBefore), MapperService.MergeReason.MAPPING_UPDATE, false);
+ DocumentMapper docMapperBefore = mapperService.merge("type1", new CompressedXContent(mappingBefore),
+ MapperService.MergeReason.MAPPING_UPDATE, false);
FieldMapper fieldMapperBefore = (FieldMapper) docMapperBefore.mappers().getMapper("copy_test");
assertEquals(Arrays.asList("foo", "bar"), fieldMapperBefore.copyTo().copyToFields());
- DocumentMapper docMapperAfter = mapperService.merge("type1", new CompressedXContent(mappingAfter), MapperService.MergeReason.MAPPING_UPDATE, false);
+ DocumentMapper docMapperAfter = mapperService.merge("type1", new CompressedXContent(mappingAfter),
+ MapperService.MergeReason.MAPPING_UPDATE, false);
FieldMapper fieldMapperAfter = (FieldMapper) docMapperAfter.mappers().getMapper("copy_test");
assertEquals(Arrays.asList("baz", "bar"), fieldMapperAfter.copyTo().copyToFields());
@@ -385,7 +393,8 @@ public void testCopyToNestedField() throws Exception {
.endArray()
.endObject();
- ParsedDocument doc = mapper.parse(SourceToParse.source("test", "type", "1", BytesReference.bytes(jsonDoc), XContentType.JSON));
+ ParsedDocument doc = mapper.parse(SourceToParse.source("test", "type", "1",
+ BytesReference.bytes(jsonDoc), XContentType.JSON));
assertEquals(6, doc.docs().size());
Document nested = doc.docs().get(0);
@@ -544,7 +553,8 @@ public void testCopyToDynamicNestedObjectParsing() throws Exception {
.endObject()
.endObject().endObject());
- DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser().parse("type1", new CompressedXContent(mapping));
+ DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("type1", new CompressedXContent(mapping));
BytesReference json = BytesReference.bytes(jsonBuilder().startObject()
.field("copy_test", "foo")
diff --git a/server/src/test/java/org/elasticsearch/index/mapper/DocumentMapperMergeTests.java b/server/src/test/java/org/elasticsearch/index/mapper/DocumentMapperMergeTests.java
index 5a0f1b76cad19..3b64a327062f6 100644
--- a/server/src/test/java/org/elasticsearch/index/mapper/DocumentMapperMergeTests.java
+++ b/server/src/test/java/org/elasticsearch/index/mapper/DocumentMapperMergeTests.java
@@ -58,7 +58,8 @@ public void test1Merge() throws Exception {
String stage2Mapping = Strings.toString(XContentFactory.jsonBuilder().startObject().startObject("person").startObject("properties")
.startObject("name").field("type", "text").endObject()
.startObject("age").field("type", "integer").endObject()
- .startObject("obj1").startObject("properties").startObject("prop1").field("type", "integer").endObject().endObject().endObject()
+ .startObject("obj1").startObject("properties").startObject("prop1").field("type", "integer")
+ .endObject().endObject().endObject()
.endObject().endObject().endObject());
DocumentMapper stage2 = parser.parse("person", new CompressedXContent(stage2Mapping));
@@ -77,7 +78,8 @@ public void testMergeObjectDynamic() throws Exception {
DocumentMapper mapper = parser.parse("type1", new CompressedXContent(objectMapping));
assertNull(mapper.root().dynamic());
- String withDynamicMapping = Strings.toString(XContentFactory.jsonBuilder().startObject().startObject("type1").field("dynamic", "false").endObject().endObject());
+ String withDynamicMapping = Strings.toString(XContentFactory.jsonBuilder().startObject().startObject("type1")
+ .field("dynamic", "false").endObject().endObject());
DocumentMapper withDynamicMapper = parser.parse("type1", new CompressedXContent(withDynamicMapping));
assertThat(withDynamicMapper.root().dynamic(), equalTo(ObjectMapper.Dynamic.FALSE));
@@ -160,7 +162,8 @@ public void testChangeSearchAnalyzerToDefault() throws Exception {
public void testConcurrentMergeTest() throws Throwable {
final MapperService mapperService = createIndex("test").mapperService();
- mapperService.merge("test", new CompressedXContent("{\"test\":{}}"), MapperService.MergeReason.MAPPING_UPDATE, false);
+ mapperService.merge("test", new CompressedXContent("{\"test\":{}}"),
+ MapperService.MergeReason.MAPPING_UPDATE, false);
final DocumentMapper documentMapper = mapperService.documentMapper("test");
DocumentFieldMappers dfm = documentMapper.mappers();
@@ -190,7 +193,8 @@ public void run() {
Mapping update = doc.dynamicMappingsUpdate();
assert update != null;
lastIntroducedFieldName.set(fieldName);
- mapperService.merge("test", new CompressedXContent(update.toString()), MapperService.MergeReason.MAPPING_UPDATE, false);
+ mapperService.merge("test", new CompressedXContent(update.toString()),
+ MapperService.MergeReason.MAPPING_UPDATE, false);
}
} catch (Exception e) {
error.set(e);
diff --git a/server/src/test/java/org/elasticsearch/index/mapper/DocumentParserTests.java b/server/src/test/java/org/elasticsearch/index/mapper/DocumentParserTests.java
index 5d78dd25be65c..5a98d7f83478b 100644
--- a/server/src/test/java/org/elasticsearch/index/mapper/DocumentParserTests.java
+++ b/server/src/test/java/org/elasticsearch/index/mapper/DocumentParserTests.java
@@ -126,19 +126,22 @@ public void testUnexpectedFieldMappingType() throws Exception {
.endObject().endObject().endObject());
DocumentMapper mapper = mapperParser.parse("type", new CompressedXContent(mapping));
{
- BytesReference bytes = BytesReference.bytes(XContentFactory.jsonBuilder().startObject().field("foo", true).endObject());
+ BytesReference bytes = BytesReference.bytes(XContentFactory.jsonBuilder().startObject().field("foo", true)
+ .endObject());
MapperException exception = expectThrows(MapperException.class,
() -> mapper.parse(SourceToParse.source("test", "type", "1", bytes, XContentType.JSON)));
assertThat(exception.getMessage(), containsString("failed to parse field [foo] of type [long]"));
}
{
- BytesReference bytes = BytesReference.bytes(XContentFactory.jsonBuilder().startObject().field("bar", "bar").endObject());
+ BytesReference bytes = BytesReference.bytes(XContentFactory.jsonBuilder().startObject().field("bar", "bar")
+ .endObject());
MapperException exception = expectThrows(MapperException.class,
() -> mapper.parse(SourceToParse.source("test", "type", "2", bytes, XContentType.JSON)));
assertThat(exception.getMessage(), containsString("failed to parse field [bar] of type [boolean]"));
}
{
- BytesReference bytes = BytesReference.bytes(XContentFactory.jsonBuilder().startObject().field("geo", 123).endObject());
+ BytesReference bytes = BytesReference.bytes(XContentFactory.jsonBuilder().startObject().field("geo", 123)
+ .endObject());
MapperException exception = expectThrows(MapperException.class,
() -> mapper.parse(SourceToParse.source("test", "type", "2", bytes, XContentType.JSON)));
assertThat(exception.getMessage(), containsString("failed to parse field [geo] of type [geo_shape]"));
@@ -396,7 +399,8 @@ public void testDynamicLongArray() throws Exception {
public void testDynamicFalseLongArray() throws Exception {
DocumentMapperParser mapperParser = createIndex("test").mapperService().documentMapperParser();
- String mapping = Strings.toString(XContentFactory.jsonBuilder().startObject().startObject("type").field("dynamic", "false")
+ String mapping = Strings.toString(XContentFactory.jsonBuilder().startObject().startObject("type")
+ .field("dynamic", "false")
.endObject().endObject());
DocumentMapper mapper = mapperParser.parse("type", new CompressedXContent(mapping));
@@ -411,7 +415,8 @@ public void testDynamicFalseLongArray() throws Exception {
public void testDynamicStrictLongArray() throws Exception {
DocumentMapperParser mapperParser = createIndex("test").mapperService().documentMapperParser();
- String mapping = Strings.toString(XContentFactory.jsonBuilder().startObject().startObject("type").field("dynamic", "strict")
+ String mapping = Strings.toString(XContentFactory.jsonBuilder().startObject().startObject("type")
+ .field("dynamic", "strict")
.endObject().endObject());
DocumentMapper mapper = mapperParser.parse("type", new CompressedXContent(mapping));
@@ -428,7 +433,8 @@ public void testDynamicStrictLongArray() throws Exception {
public void testMappedGeoPointArray() throws Exception {
DocumentMapperParser mapperParser = createIndex("test").mapperService().documentMapperParser();
String mapping = Strings.toString(XContentFactory.jsonBuilder().startObject().startObject("type")
- .startObject("properties").startObject("foo").field("type", "geo_point").field("doc_values", false)
+ .startObject("properties").startObject("foo").field("type", "geo_point")
+ .field("doc_values", false)
.endObject().endObject().endObject().endObject());
DocumentMapper mapper = mapperParser.parse("type", new CompressedXContent(mapping));
@@ -477,7 +483,8 @@ public void testDynamicObjectWithTemplate() throws Exception {
public void testDynamicFalseObject() throws Exception {
DocumentMapperParser mapperParser = createIndex("test").mapperService().documentMapperParser();
- String mapping = Strings.toString(XContentFactory.jsonBuilder().startObject().startObject("type").field("dynamic", "false")
+ String mapping = Strings.toString(XContentFactory.jsonBuilder().startObject().startObject("type")
+ .field("dynamic", "false")
.endObject().endObject());
DocumentMapper mapper = mapperParser.parse("type", new CompressedXContent(mapping));
@@ -491,7 +498,8 @@ public void testDynamicFalseObject() throws Exception {
public void testDynamicStrictObject() throws Exception {
DocumentMapperParser mapperParser = createIndex("test").mapperService().documentMapperParser();
- String mapping = Strings.toString(XContentFactory.jsonBuilder().startObject().startObject("type").field("dynamic", "strict")
+ String mapping = Strings.toString(XContentFactory.jsonBuilder().startObject().startObject("type")
+ .field("dynamic", "strict")
.endObject().endObject());
DocumentMapper mapper = mapperParser.parse("type", new CompressedXContent(mapping));
@@ -506,7 +514,8 @@ public void testDynamicStrictObject() throws Exception {
public void testDynamicFalseValue() throws Exception {
DocumentMapperParser mapperParser = createIndex("test").mapperService().documentMapperParser();
- String mapping = Strings.toString(XContentFactory.jsonBuilder().startObject().startObject("type").field("dynamic", "false")
+ String mapping = Strings.toString(XContentFactory.jsonBuilder().startObject().startObject("type")
+ .field("dynamic", "false")
.endObject().endObject());
DocumentMapper mapper = mapperParser.parse("type", new CompressedXContent(mapping));
@@ -520,7 +529,8 @@ public void testDynamicFalseValue() throws Exception {
public void testDynamicStrictValue() throws Exception {
DocumentMapperParser mapperParser = createIndex("test").mapperService().documentMapperParser();
- String mapping = Strings.toString(XContentFactory.jsonBuilder().startObject().startObject("type").field("dynamic", "strict")
+ String mapping = Strings.toString(XContentFactory.jsonBuilder().startObject().startObject("type")
+ .field("dynamic", "strict")
.endObject().endObject());
DocumentMapper mapper = mapperParser.parse("type", new CompressedXContent(mapping));
@@ -535,7 +545,8 @@ public void testDynamicStrictValue() throws Exception {
public void testDynamicFalseNull() throws Exception {
DocumentMapperParser mapperParser = createIndex("test").mapperService().documentMapperParser();
- String mapping = Strings.toString(XContentFactory.jsonBuilder().startObject().startObject("type").field("dynamic", "false")
+ String mapping = Strings.toString(XContentFactory.jsonBuilder().startObject().startObject("type")
+ .field("dynamic", "false")
.endObject().endObject());
DocumentMapper mapper = mapperParser.parse("type", new CompressedXContent(mapping));
@@ -549,7 +560,8 @@ public void testDynamicFalseNull() throws Exception {
public void testDynamicStrictNull() throws Exception {
DocumentMapperParser mapperParser = createIndex("test").mapperService().documentMapperParser();
- String mapping = Strings.toString(XContentFactory.jsonBuilder().startObject().startObject("type").field("dynamic", "strict")
+ String mapping = Strings.toString(XContentFactory.jsonBuilder().startObject().startObject("type")
+ .field("dynamic", "strict")
.endObject().endObject());
DocumentMapper mapper = mapperParser.parse("type", new CompressedXContent(mapping));
@@ -674,7 +686,8 @@ public void testDynamicDottedFieldNameLongArrayWithExistingParentWrongType() thr
public void testDynamicFalseDottedFieldNameLongArray() throws Exception {
DocumentMapperParser mapperParser = createIndex("test").mapperService().documentMapperParser();
- String mapping = Strings.toString(XContentFactory.jsonBuilder().startObject().startObject("type").field("dynamic", "false")
+ String mapping = Strings.toString(XContentFactory.jsonBuilder().startObject().startObject("type")
+ .field("dynamic", "false")
.endObject().endObject());
DocumentMapper mapper = mapperParser.parse("type", new CompressedXContent(mapping));
@@ -689,7 +702,8 @@ public void testDynamicFalseDottedFieldNameLongArray() throws Exception {
public void testDynamicStrictDottedFieldNameLongArray() throws Exception {
DocumentMapperParser mapperParser = createIndex("test").mapperService().documentMapperParser();
- String mapping = Strings.toString(XContentFactory.jsonBuilder().startObject().startObject("type").field("dynamic", "strict")
+ String mapping = Strings.toString(XContentFactory.jsonBuilder().startObject().startObject("type")
+ .field("dynamic", "strict")
.endObject().endObject());
DocumentMapper mapper = mapperParser.parse("type", new CompressedXContent(mapping));
@@ -793,7 +807,8 @@ public void testDynamicDottedFieldNameLongWithExistingParentWrongType() throws E
public void testDynamicFalseDottedFieldNameLong() throws Exception {
DocumentMapperParser mapperParser = createIndex("test").mapperService().documentMapperParser();
- String mapping = Strings.toString(XContentFactory.jsonBuilder().startObject().startObject("type").field("dynamic", "false")
+ String mapping = Strings.toString(XContentFactory.jsonBuilder().startObject().startObject("type")
+ .field("dynamic", "false")
.endObject().endObject());
DocumentMapper mapper = mapperParser.parse("type", new CompressedXContent(mapping));
@@ -806,7 +821,8 @@ public void testDynamicFalseDottedFieldNameLong() throws Exception {
public void testDynamicStrictDottedFieldNameLong() throws Exception {
DocumentMapperParser mapperParser = createIndex("test").mapperService().documentMapperParser();
- String mapping = Strings.toString(XContentFactory.jsonBuilder().startObject().startObject("type").field("dynamic", "strict")
+ String mapping = Strings.toString(XContentFactory.jsonBuilder().startObject().startObject("type")
+ .field("dynamic", "strict")
.endObject().endObject());
DocumentMapper mapper = mapperParser.parse("type", new CompressedXContent(mapping));
@@ -875,12 +891,12 @@ public void testDynamicDottedFieldNameObjectWithParentTemplate() throws Exceptio
public void testDynamicDottedFieldNameObjectWithExistingParent() throws Exception {
DocumentMapperParser mapperParser = createIndex("test").mapperService().documentMapperParser();
- String mapping = Strings.toString(XContentFactory.jsonBuilder().startObject().startObject("type").startObject("properties").startObject("foo")
- .field("type", "object").endObject().endObject().endObject().endObject());
+ String mapping = Strings.toString(XContentFactory.jsonBuilder().startObject().startObject("type").startObject("properties")
+ .startObject("foo").field("type", "object").endObject().endObject().endObject().endObject());
DocumentMapper mapper = mapperParser.parse("type", new CompressedXContent(mapping));
- BytesReference bytes = BytesReference
- .bytes(XContentFactory.jsonBuilder().startObject().startObject("foo.bar.baz").field("a", 0).endObject().endObject());
+ BytesReference bytes = BytesReference.bytes(XContentFactory.jsonBuilder().startObject().startObject("foo.bar.baz")
+ .field("a", 0).endObject().endObject());
ParsedDocument doc = mapper.parse(SourceToParse.source("test", "type", "1", bytes, XContentType.JSON));
assertEquals(2, doc.rootDoc().getFields("foo.bar.baz.a").length);
Mapper fooMapper = doc.dynamicMappingsUpdate().root().getMapper("foo");
@@ -905,8 +921,8 @@ public void testDynamicDottedFieldNameObjectWithExistingParentWrongType() throws
.endObject().endObject().endObject().endObject());
DocumentMapper mapper = mapperParser.parse("type", new CompressedXContent(mapping));
- BytesReference bytes = BytesReference
- .bytes(XContentFactory.jsonBuilder().startObject().startObject("foo.bar.baz").field("a", 0).endObject().endObject());
+ BytesReference bytes = BytesReference.bytes(XContentFactory.jsonBuilder().startObject().startObject("foo.bar.baz")
+ .field("a", 0).endObject().endObject());
MapperParsingException exception = expectThrows(MapperParsingException.class,
() -> mapper.parse(SourceToParse.source("test", "type", "1", bytes, XContentType.JSON)));
@@ -916,7 +932,8 @@ public void testDynamicDottedFieldNameObjectWithExistingParentWrongType() throws
public void testDynamicFalseDottedFieldNameObject() throws Exception {
DocumentMapperParser mapperParser = createIndex("test").mapperService().documentMapperParser();
- String mapping = Strings.toString(XContentFactory.jsonBuilder().startObject().startObject("type").field("dynamic", "false")
+ String mapping = Strings.toString(XContentFactory.jsonBuilder().startObject().startObject("type")
+ .field("dynamic", "false")
.endObject().endObject());
DocumentMapper mapper = mapperParser.parse("type", new CompressedXContent(mapping));
@@ -930,7 +947,8 @@ public void testDynamicFalseDottedFieldNameObject() throws Exception {
public void testDynamicStrictDottedFieldNameObject() throws Exception {
DocumentMapperParser mapperParser = createIndex("test").mapperService().documentMapperParser();
- String mapping = Strings.toString(XContentFactory.jsonBuilder().startObject().startObject("type").field("dynamic", "strict")
+ String mapping = Strings.toString(XContentFactory.jsonBuilder().startObject().startObject("type")
+ .field("dynamic", "strict")
.endObject().endObject());
DocumentMapper mapper = mapperParser.parse("type", new CompressedXContent(mapping));
@@ -953,7 +971,8 @@ public void testDocumentContainsMetadataField() throws Exception {
mapper.parse(SourceToParse.source("test", "type", "1", bytes, XContentType.JSON)));
assertTrue(e.getMessage(), e.getMessage().contains("cannot be added inside a document"));
- BytesReference bytes2 = BytesReference.bytes(XContentFactory.jsonBuilder().startObject().field("foo._ttl", 0).endObject());
+ BytesReference bytes2 = BytesReference.bytes(XContentFactory.jsonBuilder().startObject()
+ .field("foo._ttl", 0).endObject());
mapper.parse(SourceToParse.source("test", "type", "1", bytes2, XContentType.JSON)); // parses without error
}
@@ -961,7 +980,8 @@ public void testSimpleMapper() throws Exception {
IndexService indexService = createIndex("test");
DocumentMapper docMapper = new DocumentMapper.Builder(
new RootObjectMapper.Builder("person")
- .add(new ObjectMapper.Builder("name").add(new TextFieldMapper.Builder("first").store(true).index(false))),
+ .add(new ObjectMapper.Builder("name")
+ .add(new TextFieldMapper.Builder("first").store(true).index(false))),
indexService.mapperService()).build(indexService.mapperService());
BytesReference json = new BytesArray(copyToBytesFromClasspath("/org/elasticsearch/index/mapper/simple/test1.json"));
@@ -986,7 +1006,8 @@ public void testParseToJsonAndParse() throws Exception {
public void testSimpleParser() throws Exception {
String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/simple/test-mapping.json");
- DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser().parse("person", new CompressedXContent(mapping));
+ DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("person", new CompressedXContent(mapping));
assertThat((String) docMapper.meta().get("param1"), equalTo("value1"));
@@ -998,7 +1019,8 @@ public void testSimpleParser() throws Exception {
public void testSimpleParserNoTypeNoId() throws Exception {
String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/simple/test-mapping.json");
- DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser().parse("person", new CompressedXContent(mapping));
+ DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("person", new CompressedXContent(mapping));
BytesReference json = new BytesArray(copyToBytesFromClasspath("/org/elasticsearch/index/mapper/simple/test1-notype-noid.json"));
Document doc = docMapper.parse(SourceToParse.source("test", "person", "1", json, XContentType.JSON)).rootDoc();
assertThat(doc.getBinaryValue(docMapper.idFieldMapper().name()), equalTo(Uid.encodeId("1")));
@@ -1021,7 +1043,8 @@ public void testNoDocumentSent() throws Exception {
IndexService indexService = createIndex("test");
DocumentMapper docMapper = new DocumentMapper.Builder(
new RootObjectMapper.Builder("person")
- .add(new ObjectMapper.Builder("name").add(new TextFieldMapper.Builder("first").store(true).index(false))),
+ .add(new ObjectMapper.Builder("name")
+ .add(new TextFieldMapper.Builder("first").store(true).index(false))),
indexService.mapperService()).build(indexService.mapperService());
BytesReference json = new BytesArray("".getBytes(StandardCharsets.UTF_8));
@@ -1036,7 +1059,8 @@ public void testNoDocumentSent() throws Exception {
public void testNoLevel() throws Exception {
String defaultMapping = Strings.toString(XContentFactory.jsonBuilder().startObject().startObject("type").endObject().endObject());
- DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser().parse("type", new CompressedXContent(defaultMapping));
+ DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("type", new CompressedXContent(defaultMapping));
ParsedDocument doc = defaultMapper.parse(SourceToParse.source("test", "type", "1", BytesReference
.bytes(XContentFactory.jsonBuilder()
@@ -1055,7 +1079,8 @@ public void testNoLevel() throws Exception {
public void testTypeLevel() throws Exception {
String defaultMapping = Strings.toString(XContentFactory.jsonBuilder().startObject().startObject("type").endObject().endObject());
- DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser().parse("type", new CompressedXContent(defaultMapping));
+ DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("type", new CompressedXContent(defaultMapping));
ParsedDocument doc = defaultMapper.parse(SourceToParse.source("test", "type", "1", BytesReference
.bytes(XContentFactory.jsonBuilder()
@@ -1074,7 +1099,8 @@ public void testTypeLevel() throws Exception {
public void testNoLevelWithFieldTypeAsValue() throws Exception {
String defaultMapping = Strings.toString(XContentFactory.jsonBuilder().startObject().startObject("type").endObject().endObject());
- DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser().parse("type", new CompressedXContent(defaultMapping));
+ DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("type", new CompressedXContent(defaultMapping));
ParsedDocument doc = defaultMapper.parse(SourceToParse.source("test", "type", "1", BytesReference
.bytes(XContentFactory.jsonBuilder()
@@ -1095,7 +1121,8 @@ public void testNoLevelWithFieldTypeAsValue() throws Exception {
public void testTypeLevelWithFieldTypeAsValue() throws Exception {
String defaultMapping = Strings.toString(XContentFactory.jsonBuilder().startObject().startObject("type").endObject().endObject());
- DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser().parse("type", new CompressedXContent(defaultMapping));
+ DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("type", new CompressedXContent(defaultMapping));
ParsedDocument doc = defaultMapper.parse(SourceToParse.source("test", "type", "1", BytesReference
.bytes(XContentFactory.jsonBuilder()
@@ -1116,7 +1143,8 @@ public void testTypeLevelWithFieldTypeAsValue() throws Exception {
public void testNoLevelWithFieldTypeAsObject() throws Exception {
String defaultMapping = Strings.toString(XContentFactory.jsonBuilder().startObject().startObject("type").endObject().endObject());
- DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser().parse("type", new CompressedXContent(defaultMapping));
+ DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("type", new CompressedXContent(defaultMapping));
ParsedDocument doc = defaultMapper.parse(SourceToParse.source("test", "type", "1", BytesReference
.bytes(XContentFactory.jsonBuilder()
@@ -1137,7 +1165,8 @@ public void testNoLevelWithFieldTypeAsObject() throws Exception {
public void testTypeLevelWithFieldTypeAsObject() throws Exception {
String defaultMapping = Strings.toString(XContentFactory.jsonBuilder().startObject().startObject("type").endObject().endObject());
- DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser().parse("type", new CompressedXContent(defaultMapping));
+ DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("type", new CompressedXContent(defaultMapping));
ParsedDocument doc = defaultMapper.parse(SourceToParse.source("test", "type", "1", BytesReference
.bytes(XContentFactory.jsonBuilder()
@@ -1158,7 +1187,8 @@ public void testTypeLevelWithFieldTypeAsObject() throws Exception {
public void testNoLevelWithFieldTypeAsValueNotFirst() throws Exception {
String defaultMapping = Strings.toString(XContentFactory.jsonBuilder().startObject().startObject("type").endObject().endObject());
- DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser().parse("type", new CompressedXContent(defaultMapping));
+ DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("type", new CompressedXContent(defaultMapping));
ParsedDocument doc = defaultMapper.parse(SourceToParse.source("test", "type", "1", BytesReference
.bytes(XContentFactory.jsonBuilder()
@@ -1179,7 +1209,8 @@ public void testNoLevelWithFieldTypeAsValueNotFirst() throws Exception {
public void testTypeLevelWithFieldTypeAsValueNotFirst() throws Exception {
String defaultMapping = Strings.toString(XContentFactory.jsonBuilder().startObject().startObject("type").endObject().endObject());
- DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser().parse("type", new CompressedXContent(defaultMapping));
+ DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("type", new CompressedXContent(defaultMapping));
ParsedDocument doc = defaultMapper.parse(SourceToParse.source("test", "type", "1", BytesReference
.bytes(XContentFactory.jsonBuilder()
@@ -1200,7 +1231,8 @@ public void testTypeLevelWithFieldTypeAsValueNotFirst() throws Exception {
public void testNoLevelWithFieldTypeAsObjectNotFirst() throws Exception {
String defaultMapping = Strings.toString(XContentFactory.jsonBuilder().startObject().startObject("type").endObject().endObject());
- DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser().parse("type", new CompressedXContent(defaultMapping));
+ DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("type", new CompressedXContent(defaultMapping));
ParsedDocument doc = defaultMapper.parse(SourceToParse.source("test", "type", "1", BytesReference
.bytes(XContentFactory.jsonBuilder()
@@ -1222,7 +1254,8 @@ public void testNoLevelWithFieldTypeAsObjectNotFirst() throws Exception {
public void testTypeLevelWithFieldTypeAsObjectNotFirst() throws Exception {
String defaultMapping = Strings.toString(XContentFactory.jsonBuilder().startObject().startObject("type").endObject().endObject());
- DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser().parse("type", new CompressedXContent(defaultMapping));
+ DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("type", new CompressedXContent(defaultMapping));
ParsedDocument doc = defaultMapper.parse(SourceToParse.source("test", "type", "1", BytesReference
.bytes(XContentFactory.jsonBuilder()
@@ -1313,7 +1346,7 @@ public void testDynamicFieldsStartingAndEndingWithDot() throws Exception {
fail("should have failed to dynamically introduce a double-dot field");
} catch (IllegalArgumentException e) {
assertThat(e.getMessage(),
- containsString("object field starting or ending with a [.] makes object resolution ambiguous: [top..foo..bar]"));
+ containsString("object field starting or ending with a [.] makes object resolution ambiguous: [top..foo..bar]"));
}
}
diff --git a/server/src/test/java/org/elasticsearch/index/mapper/DynamicMappingTests.java b/server/src/test/java/org/elasticsearch/index/mapper/DynamicMappingTests.java
index 81a9734940b05..06a5c87d52f07 100644
--- a/server/src/test/java/org/elasticsearch/index/mapper/DynamicMappingTests.java
+++ b/server/src/test/java/org/elasticsearch/index/mapper/DynamicMappingTests.java
@@ -68,7 +68,8 @@ public void testDynamicTrue() throws IOException {
.endObject()
.endObject().endObject());
- DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser().parse("type", new CompressedXContent(mapping));
+ DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("type", new CompressedXContent(mapping));
ParsedDocument doc = defaultMapper.parse(SourceToParse.source("test", "type", "1", BytesReference
.bytes(jsonBuilder()
@@ -90,7 +91,8 @@ public void testDynamicFalse() throws IOException {
.endObject()
.endObject().endObject());
- DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser().parse("type", new CompressedXContent(mapping));
+ DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("type", new CompressedXContent(mapping));
ParsedDocument doc = defaultMapper.parse(SourceToParse.source("test", "type", "1", BytesReference
.bytes(jsonBuilder()
@@ -113,10 +115,12 @@ public void testDynamicStrict() throws IOException {
.endObject()
.endObject().endObject());
- DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser().parse("type", new CompressedXContent(mapping));
+ DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("type", new CompressedXContent(mapping));
- StrictDynamicMappingException e = expectThrows(StrictDynamicMappingException.class, () -> defaultMapper.parse(SourceToParse.source("test", "type", "1", BytesReference
- .bytes(jsonBuilder()
+ StrictDynamicMappingException e = expectThrows(StrictDynamicMappingException.class,
+ () -> defaultMapper.parse(SourceToParse.source("test", "type", "1",
+ BytesReference.bytes(jsonBuilder()
.startObject()
.field("field1", "value1")
.field("field2", "value2")
@@ -124,8 +128,9 @@ public void testDynamicStrict() throws IOException {
XContentType.JSON)));
assertThat(e.getMessage(), equalTo("mapping set to strict, dynamic introduction of [field2] within [type] is not allowed"));
- e = expectThrows(StrictDynamicMappingException.class, () -> defaultMapper.parse(SourceToParse.source("test", "type", "1", BytesReference
- .bytes(XContentFactory.jsonBuilder()
+ e = expectThrows(StrictDynamicMappingException.class,
+ () -> defaultMapper.parse(SourceToParse.source("test", "type", "1",
+ BytesReference.bytes(XContentFactory.jsonBuilder()
.startObject()
.field("field1", "value1")
.field("field2", (String) null)
@@ -144,10 +149,11 @@ public void testDynamicFalseWithInnerObjectButDynamicSetOnRoot() throws IOExcept
.endObject()
.endObject().endObject());
- DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser().parse("type", new CompressedXContent(mapping));
+ DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("type", new CompressedXContent(mapping));
- ParsedDocument doc = defaultMapper.parse(SourceToParse.source("test", "type", "1", BytesReference
- .bytes(jsonBuilder()
+ ParsedDocument doc = defaultMapper.parse(SourceToParse.source("test", "type", "1",
+ BytesReference.bytes(jsonBuilder()
.startObject().startObject("obj1")
.field("field1", "value1")
.field("field2", "value2")
@@ -169,11 +175,12 @@ public void testDynamicStrictWithInnerObjectButDynamicSetOnRoot() throws IOExcep
.endObject()
.endObject().endObject());
- DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser().parse("type", new CompressedXContent(mapping));
+ DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("type", new CompressedXContent(mapping));
StrictDynamicMappingException e = expectThrows(StrictDynamicMappingException.class, () ->
- defaultMapper.parse(SourceToParse.source("test", "type", "1", BytesReference
- .bytes(jsonBuilder()
+ defaultMapper.parse(SourceToParse.source("test", "type", "1",
+ BytesReference.bytes(jsonBuilder()
.startObject().startObject("obj1")
.field("field1", "value1")
.field("field2", "value2")
@@ -225,7 +232,8 @@ private Mapper parse(DocumentMapper mapper, DocumentMapperParser parser, XConten
.settings(Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT))
.numberOfShards(1).numberOfReplicas(0).build();
IndexSettings settings = new IndexSettings(build, Settings.EMPTY);
- SourceToParse source = SourceToParse.source("test", mapper.type(), "some_id", BytesReference.bytes(builder), builder.contentType());
+ SourceToParse source = SourceToParse.source("test", mapper.type(), "some_id",
+ BytesReference.bytes(builder), builder.contentType());
try (XContentParser xContentParser = createParser(JsonXContent.jsonXContent, source.source())) {
ParseContext.InternalParseContext ctx = new ParseContext.InternalParseContext(settings, parser, mapper, source, xContentParser);
assertEquals(XContentParser.Token.START_OBJECT, ctx.parser().nextToken());
@@ -289,7 +297,8 @@ public void testIncremental() throws Exception {
DocumentMapper mapper = parser.parse("type", new CompressedXContent(mapping));
assertEquals(mapping, serialize(mapper));
- Mapper update = parse(mapper, parser, XContentFactory.jsonBuilder().startObject().field("foo", "bar").field("bar", "baz").endObject());
+ Mapper update = parse(mapper, parser, XContentFactory.jsonBuilder().startObject().field("foo", "bar")
+ .field("bar", "baz").endObject());
assertNotNull(update);
// original mapping not modified
assertEquals(mapping, serialize(mapper));
@@ -317,7 +326,8 @@ public void testIntroduceTwoFields() throws Exception {
DocumentMapper mapper = parser.parse("type", new CompressedXContent(mapping));
assertEquals(mapping, serialize(mapper));
- Mapper update = parse(mapper, parser, XContentFactory.jsonBuilder().startObject().field("foo", "bar").field("bar", "baz").endObject());
+ Mapper update = parse(mapper, parser, XContentFactory.jsonBuilder().startObject().field("foo", "bar")
+ .field("bar", "baz").endObject());
assertNotNull(update);
// original mapping not modified
assertEquals(mapping, serialize(mapper));
@@ -352,14 +362,17 @@ public void testObject() throws Exception {
DocumentMapper mapper = parser.parse("type", new CompressedXContent(mapping));
assertEquals(mapping, serialize(mapper));
- Mapper update = parse(mapper, parser, XContentFactory.jsonBuilder().startObject().startObject("foo").startObject("bar").field("baz", "foo").endObject().endObject().endObject());
+ Mapper update = parse(mapper, parser, XContentFactory.jsonBuilder().startObject().startObject("foo").startObject("bar")
+ .field("baz", "foo").endObject().endObject().endObject());
assertNotNull(update);
// original mapping not modified
assertEquals(mapping, serialize(mapper));
// but we have an update
assertEquals(Strings.toString(XContentFactory.jsonBuilder().startObject().startObject("type").startObject("properties")
- .startObject("foo").startObject("properties").startObject("bar").startObject("properties").startObject("baz").field("type", "text")
- .startObject("fields").startObject("keyword").field("type", "keyword").field("ignore_above", 256).endObject()
+ .startObject("foo").startObject("properties").startObject("bar").startObject("properties").startObject("baz")
+ .field("type", "text")
+ .startObject("fields").startObject("keyword").field("type", "keyword")
+ .field("ignore_above", 256).endObject()
.endObject().endObject().endObject().endObject().endObject().endObject()
.endObject().endObject().endObject()), serialize(update));
}
@@ -374,7 +387,8 @@ public void testArray() throws Exception {
DocumentMapper mapper = parser.parse("type", new CompressedXContent(mapping));
assertEquals(mapping, serialize(mapper));
- Mapper update = parse(mapper, parser, XContentFactory.jsonBuilder().startObject().startArray("foo").value("bar").value("baz").endArray().endObject());
+ Mapper update = parse(mapper, parser, XContentFactory.jsonBuilder().startObject()
+ .startArray("foo").value("bar").value("baz").endArray().endObject());
assertNotNull(update);
// original mapping not modified
assertEquals(mapping, serialize(mapper));
@@ -402,13 +416,15 @@ public void testInnerDynamicMapping() throws Exception {
DocumentMapper mapper = parser.parse("type", new CompressedXContent(mapping));
assertEquals(mapping, serialize(mapper));
- Mapper update = parse(mapper, parser, XContentFactory.jsonBuilder().startObject().startObject("foo").startObject("bar").field("baz", "foo").endObject().endObject().endObject());
+ Mapper update = parse(mapper, parser, XContentFactory.jsonBuilder().startObject().startObject("foo")
+ .startObject("bar").field("baz", "foo").endObject().endObject().endObject());
assertNotNull(update);
// original mapping not modified
assertEquals(mapping, serialize(mapper));
// but we have an update
assertEquals(Strings.toString(XContentFactory.jsonBuilder().startObject().startObject("type").startObject("properties")
- .startObject("foo").startObject("properties").startObject("bar").startObject("properties").startObject("baz").field("type", "text").startObject("fields")
+ .startObject("foo").startObject("properties").startObject("bar").startObject("properties")
+ .startObject("baz").field("type", "text").startObject("fields")
.startObject("keyword").field("type", "keyword").field("ignore_above", 256).endObject()
.endObject().endObject().endObject().endObject().endObject().endObject()
.endObject().endObject().endObject()), serialize(update));
@@ -605,7 +621,8 @@ private void doTestDefaultFloatingPointMappings(DocumentMapper mapper, XContentB
.field("baz", (double) 3.2f) // double that can be accurately represented as a float
.field("quux", "3.2") // float detected through numeric detection
.endObject());
- ParsedDocument parsedDocument = mapper.parse(SourceToParse.source("index", "type", "id", source, builder.contentType()));
+ ParsedDocument parsedDocument = mapper.parse(SourceToParse.source("index", "type", "id",
+ source, builder.contentType()));
Mapping update = parsedDocument.dynamicMappingsUpdate();
assertNotNull(update);
assertThat(((FieldMapper) update.root().getMapper("foo")).fieldType().typeName(), equalTo("float"));
diff --git a/server/src/test/java/org/elasticsearch/index/mapper/ExternalMapper.java b/server/src/test/java/org/elasticsearch/index/mapper/ExternalMapper.java
index 3ae45aab49aed..e42504e8e9094 100644
--- a/server/src/test/java/org/elasticsearch/index/mapper/ExternalMapper.java
+++ b/server/src/test/java/org/elasticsearch/index/mapper/ExternalMapper.java
@@ -92,8 +92,8 @@ public ExternalMapper build(BuilderContext context) {
setupFieldType(context);
- return new ExternalMapper(name, fieldType, generatedValue, mapperName, binMapper, boolMapper, pointMapper, shapeMapper, stringMapper,
- context.indexSettings(), multiFieldsBuilder.build(this, context), copyTo);
+ return new ExternalMapper(name, fieldType, generatedValue, mapperName, binMapper, boolMapper, pointMapper,
+ shapeMapper, stringMapper, context.indexSettings(), multiFieldsBuilder.build(this, context), copyTo);
}
}
@@ -156,7 +156,8 @@ public Query existsQuery(QueryShardContext context) {
public ExternalMapper(String simpleName, MappedFieldType fieldType,
String generatedValue, String mapperName,
BinaryFieldMapper binMapper, BooleanFieldMapper boolMapper, GeoPointFieldMapper pointMapper,
- GeoShapeFieldMapper shapeMapper, FieldMapper stringMapper, Settings indexSettings, MultiFields multiFields, CopyTo copyTo) {
+ GeoShapeFieldMapper shapeMapper, FieldMapper stringMapper, Settings indexSettings,
+ MultiFields multiFields, CopyTo copyTo) {
super(simpleName, fieldType, new ExternalFieldType(), indexSettings, multiFields, copyTo);
this.generatedValue = generatedValue;
this.mapperName = mapperName;
diff --git a/server/src/test/java/org/elasticsearch/index/mapper/ExternalMetadataMapper.java b/server/src/test/java/org/elasticsearch/index/mapper/ExternalMetadataMapper.java
index 2ae6345d44e6e..e8c38bc1a5a93 100644
--- a/server/src/test/java/org/elasticsearch/index/mapper/ExternalMetadataMapper.java
+++ b/server/src/test/java/org/elasticsearch/index/mapper/ExternalMetadataMapper.java
@@ -24,13 +24,6 @@
import org.apache.lucene.index.IndexableField;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentBuilder;
-import org.elasticsearch.index.mapper.BooleanFieldMapper;
-import org.elasticsearch.index.mapper.MappedFieldType;
-import org.elasticsearch.index.mapper.Mapper;
-import org.elasticsearch.index.mapper.MapperParsingException;
-import org.elasticsearch.index.mapper.MetadataFieldMapper;
-import org.elasticsearch.index.mapper.ParseContext;
-import org.elasticsearch.index.mapper.Mapper.TypeParser.ParserContext;
import java.io.IOException;
import java.util.Collections;
@@ -99,7 +92,8 @@ public ExternalMetadataMapper build(BuilderContext context) {
public static class TypeParser implements MetadataFieldMapper.TypeParser {
@Override
- public MetadataFieldMapper.Builder, ?> parse(String name, Map node, ParserContext parserContext) throws MapperParsingException {
+ public MetadataFieldMapper.Builder, ?> parse(String name, Map node,
+ ParserContext parserContext) throws MapperParsingException {
return new Builder();
}
diff --git a/server/src/test/java/org/elasticsearch/index/mapper/FieldNamesFieldMapperTests.java b/server/src/test/java/org/elasticsearch/index/mapper/FieldNamesFieldMapperTests.java
index 32a2f73536a00..5653b0cb9c533 100644
--- a/server/src/test/java/org/elasticsearch/index/mapper/FieldNamesFieldMapperTests.java
+++ b/server/src/test/java/org/elasticsearch/index/mapper/FieldNamesFieldMapperTests.java
@@ -67,7 +67,8 @@ public void testFieldType() throws Exception {
.startObject("_field_names").endObject()
.endObject().endObject());
- DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser().parse("type", new CompressedXContent(mapping));
+ DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("type", new CompressedXContent(mapping));
FieldNamesFieldMapper fieldNamesMapper = docMapper.metadataMapper(FieldNamesFieldMapper.class);
assertFalse(fieldNamesMapper.fieldType().hasDocValues());
assertEquals(IndexOptions.DOCS, fieldNamesMapper.fieldType().indexOptions());
@@ -78,10 +79,11 @@ public void testFieldType() throws Exception {
public void testInjectIntoDocDuringParsing() throws Exception {
String mapping = Strings.toString(XContentFactory.jsonBuilder().startObject().startObject("type").endObject().endObject());
- DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser().parse("type", new CompressedXContent(mapping));
+ DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("type", new CompressedXContent(mapping));
- ParsedDocument doc = defaultMapper.parse(SourceToParse.source("test", "type", "1", BytesReference
- .bytes(XContentFactory.jsonBuilder()
+ ParsedDocument doc = defaultMapper.parse(SourceToParse.source("test", "type", "1",
+ BytesReference.bytes(XContentFactory.jsonBuilder()
.startObject()
.field("a", "100")
.startObject("b")
@@ -96,14 +98,16 @@ public void testInjectIntoDocDuringParsing() throws Exception {
public void testExplicitEnabled() throws Exception {
String mapping = Strings.toString(XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("_field_names").field("enabled", true).endObject()
- .startObject("properties").startObject("field").field("type", "keyword").field("doc_values", false).endObject().endObject()
- .endObject().endObject());
- DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser().parse("type", new CompressedXContent(mapping));
+ .startObject("properties")
+ .startObject("field").field("type", "keyword").field("doc_values", false).endObject()
+ .endObject().endObject().endObject());
+ DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("type", new CompressedXContent(mapping));
FieldNamesFieldMapper fieldNamesMapper = docMapper.metadataMapper(FieldNamesFieldMapper.class);
assertTrue(fieldNamesMapper.fieldType().isEnabled());
- ParsedDocument doc = docMapper.parse(SourceToParse.source("test", "type", "1", BytesReference
- .bytes(XContentFactory.jsonBuilder()
+ ParsedDocument doc = docMapper.parse(SourceToParse.source("test", "type", "1",
+ BytesReference.bytes(XContentFactory.jsonBuilder()
.startObject()
.field("field", "value")
.endObject()),
@@ -116,12 +120,13 @@ public void testDisabled() throws Exception {
String mapping = Strings.toString(XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("_field_names").field("enabled", false).endObject()
.endObject().endObject());
- DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser().parse("type", new CompressedXContent(mapping));
+ DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("type", new CompressedXContent(mapping));
FieldNamesFieldMapper fieldNamesMapper = docMapper.metadataMapper(FieldNamesFieldMapper.class);
assertFalse(fieldNamesMapper.fieldType().isEnabled());
- ParsedDocument doc = docMapper.parse(SourceToParse.source("test", "type", "1", BytesReference
- .bytes(XContentFactory.jsonBuilder()
+ ParsedDocument doc = docMapper.parse(SourceToParse.source("test", "type", "1",
+ BytesReference.bytes(XContentFactory.jsonBuilder()
.startObject()
.field("field", "value")
.endObject()),
@@ -139,11 +144,14 @@ public void testMergingMappings() throws Exception {
.endObject().endObject());
MapperService mapperService = createIndex("test").mapperService();
- DocumentMapper mapperEnabled = mapperService.merge("type", new CompressedXContent(enabledMapping), MapperService.MergeReason.MAPPING_UPDATE, false);
- DocumentMapper mapperDisabled = mapperService.merge("type", new CompressedXContent(disabledMapping), MapperService.MergeReason.MAPPING_UPDATE, false);
+ DocumentMapper mapperEnabled = mapperService.merge("type", new CompressedXContent(enabledMapping),
+ MapperService.MergeReason.MAPPING_UPDATE, false);
+ DocumentMapper mapperDisabled = mapperService.merge("type", new CompressedXContent(disabledMapping),
+ MapperService.MergeReason.MAPPING_UPDATE, false);
assertFalse(mapperDisabled.metadataMapper(FieldNamesFieldMapper.class).fieldType().isEnabled());
- mapperEnabled = mapperService.merge("type", new CompressedXContent(enabledMapping), MapperService.MergeReason.MAPPING_UPDATE, false);
+ mapperEnabled = mapperService.merge("type", new CompressedXContent(enabledMapping),
+ MapperService.MergeReason.MAPPING_UPDATE, false);
assertTrue(mapperEnabled.metadataMapper(FieldNamesFieldMapper.class).fieldType().isEnabled());
}
}
diff --git a/server/src/test/java/org/elasticsearch/index/mapper/GeoPointFieldMapperTests.java b/server/src/test/java/org/elasticsearch/index/mapper/GeoPointFieldMapperTests.java
index eabf0a849fa39..b3474fb5efbcd 100644
--- a/server/src/test/java/org/elasticsearch/index/mapper/GeoPointFieldMapperTests.java
+++ b/server/src/test/java/org/elasticsearch/index/mapper/GeoPointFieldMapperTests.java
@@ -62,10 +62,11 @@ public void testGeoHashValue() throws Exception {
XContentBuilder xContentBuilder = XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("properties").startObject("point").field("type", "geo_point");
String mapping = Strings.toString(xContentBuilder.endObject().endObject().endObject().endObject());
- DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser().parse("type", new CompressedXContent(mapping));
+ DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("type", new CompressedXContent(mapping));
- ParsedDocument doc = defaultMapper.parse(SourceToParse.source("test", "type", "1", BytesReference
- .bytes(XContentFactory.jsonBuilder()
+ ParsedDocument doc = defaultMapper.parse(SourceToParse.source("test", "type", "1",
+ BytesReference.bytes(XContentFactory.jsonBuilder()
.startObject()
.field("point", stringEncode(1.3, 1.2))
.endObject()),
@@ -78,10 +79,11 @@ public void testLatLonValuesStored() throws Exception {
XContentBuilder xContentBuilder = XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("properties").startObject("point").field("type", "geo_point");
String mapping = Strings.toString(xContentBuilder.field("store", true).endObject().endObject().endObject().endObject());
- DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser().parse("type", new CompressedXContent(mapping));
+ DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("type", new CompressedXContent(mapping));
- ParsedDocument doc = defaultMapper.parse(SourceToParse.source("test", "type", "1", BytesReference
- .bytes(XContentFactory.jsonBuilder()
+ ParsedDocument doc = defaultMapper.parse(SourceToParse.source("test", "type", "1",
+ BytesReference.bytes(XContentFactory.jsonBuilder()
.startObject()
.startObject("point").field("lat", 1.2).field("lon", 1.3).endObject()
.endObject()),
@@ -94,10 +96,11 @@ public void testArrayLatLonValues() throws Exception {
XContentBuilder xContentBuilder = XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("properties").startObject("point").field("type", "geo_point").field("doc_values", false);
String mapping = Strings.toString(xContentBuilder.field("store", true).endObject().endObject().endObject().endObject());
- DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser().parse("type", new CompressedXContent(mapping));
+ DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("type", new CompressedXContent(mapping));
- ParsedDocument doc = defaultMapper.parse(SourceToParse.source("test", "type", "1", BytesReference
- .bytes(XContentFactory.jsonBuilder()
+ ParsedDocument doc = defaultMapper.parse(SourceToParse.source("test", "type", "1",
+ BytesReference.bytes(XContentFactory.jsonBuilder()
.startObject()
.startArray("point")
.startObject().field("lat", 1.2).field("lon", 1.3).endObject()
@@ -115,11 +118,11 @@ public void testLatLonInOneValue() throws Exception {
XContentBuilder xContentBuilder = XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("properties").startObject("point").field("type", "geo_point");
String mapping = Strings.toString(xContentBuilder.endObject().endObject().endObject().endObject());
- DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser().parse("type",
- new CompressedXContent(mapping));
+ DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("type", new CompressedXContent(mapping));
- ParsedDocument doc = defaultMapper.parse(SourceToParse.source("test", "type", "1", BytesReference
- .bytes(XContentFactory.jsonBuilder()
+ ParsedDocument doc = defaultMapper.parse(SourceToParse.source("test", "type", "1",
+ BytesReference.bytes(XContentFactory.jsonBuilder()
.startObject()
.field("point", "1.2,1.3")
.endObject()),
@@ -133,11 +136,11 @@ public void testLatLonStringWithZValue() throws Exception {
.startObject("properties").startObject("point").field("type", "geo_point")
.field(IGNORE_Z_VALUE.getPreferredName(), true);
String mapping = Strings.toString(xContentBuilder.endObject().endObject().endObject().endObject());
- DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser().parse("type",
- new CompressedXContent(mapping));
+ DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("type", new CompressedXContent(mapping));
- ParsedDocument doc = defaultMapper.parse(SourceToParse.source("test", "type", "1", BytesReference
- .bytes(XContentFactory.jsonBuilder()
+ ParsedDocument doc = defaultMapper.parse(SourceToParse.source("test", "type", "1",
+ BytesReference.bytes(XContentFactory.jsonBuilder()
.startObject()
.field("point", "1.2,1.3,10.0")
.endObject()),
@@ -151,11 +154,11 @@ public void testLatLonStringWithZValueException() throws Exception {
.startObject("properties").startObject("point").field("type", "geo_point")
.field(IGNORE_Z_VALUE.getPreferredName(), false);
String mapping = Strings.toString(xContentBuilder.endObject().endObject().endObject().endObject());
- DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser().parse("type",
- new CompressedXContent(mapping));
+ DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("type", new CompressedXContent(mapping));
- SourceToParse source = SourceToParse.source("test", "type", "1", BytesReference
- .bytes(XContentFactory.jsonBuilder()
+ SourceToParse source = SourceToParse.source("test", "type", "1",
+ BytesReference.bytes(XContentFactory.jsonBuilder()
.startObject()
.field("point", "1.2,1.3,10.0")
.endObject()),
@@ -169,11 +172,11 @@ public void testLatLonInOneValueStored() throws Exception {
XContentBuilder xContentBuilder = XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("properties").startObject("point").field("type", "geo_point");
String mapping = Strings.toString(xContentBuilder.field("store", true).endObject().endObject().endObject().endObject());
- DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser().parse("type",
- new CompressedXContent(mapping));
+ DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("type", new CompressedXContent(mapping));
- ParsedDocument doc = defaultMapper.parse(SourceToParse.source("test", "type", "1", BytesReference
- .bytes(XContentFactory.jsonBuilder()
+ ParsedDocument doc = defaultMapper.parse(SourceToParse.source("test", "type", "1",
+ BytesReference.bytes(XContentFactory.jsonBuilder()
.startObject()
.field("point", "1.2,1.3")
.endObject()),
@@ -185,11 +188,11 @@ public void testLatLonInOneValueArray() throws Exception {
XContentBuilder xContentBuilder = XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("properties").startObject("point").field("type", "geo_point").field("doc_values", false);
String mapping = Strings.toString(xContentBuilder.field("store", true).endObject().endObject().endObject().endObject());
- DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser().parse("type",
- new CompressedXContent(mapping));
+ DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("type", new CompressedXContent(mapping));
- ParsedDocument doc = defaultMapper.parse(SourceToParse.source("test", "type", "1", BytesReference
- .bytes(XContentFactory.jsonBuilder()
+ ParsedDocument doc = defaultMapper.parse(SourceToParse.source("test", "type", "1",
+ BytesReference.bytes(XContentFactory.jsonBuilder()
.startObject()
.startArray("point")
.value("1.2,1.3")
@@ -207,10 +210,11 @@ public void testLonLatArray() throws Exception {
XContentBuilder xContentBuilder = XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("properties").startObject("point").field("type", "geo_point");
String mapping = Strings.toString(xContentBuilder.endObject().endObject().endObject().endObject());
- DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser().parse("type", new CompressedXContent(mapping));
+ DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("type", new CompressedXContent(mapping));
- ParsedDocument doc = defaultMapper.parse(SourceToParse.source("test", "type", "1", BytesReference
- .bytes(XContentFactory.jsonBuilder()
+ ParsedDocument doc = defaultMapper.parse(SourceToParse.source("test", "type", "1",
+ BytesReference.bytes(XContentFactory.jsonBuilder()
.startObject()
.startArray("point").value(1.3).value(1.2).endArray()
.endObject()),
@@ -224,10 +228,11 @@ public void testLonLatArrayDynamic() throws Exception {
.startArray("dynamic_templates").startObject().startObject("point").field("match", "point*")
.startObject("mapping").field("type", "geo_point");
String mapping = Strings.toString(xContentBuilder.endObject().endObject().endObject().endArray().endObject().endObject());
- DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser().parse("type", new CompressedXContent(mapping));
+ DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("type", new CompressedXContent(mapping));
- ParsedDocument doc = defaultMapper.parse(SourceToParse.source("test", "type", "1", BytesReference
- .bytes(XContentFactory.jsonBuilder()
+ ParsedDocument doc = defaultMapper.parse(SourceToParse.source("test", "type", "1",
+ BytesReference.bytes(XContentFactory.jsonBuilder()
.startObject()
.startArray("point").value(1.3).value(1.2).endArray()
.endObject()),
@@ -240,10 +245,11 @@ public void testLonLatArrayStored() throws Exception {
XContentBuilder xContentBuilder = XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("properties").startObject("point").field("type", "geo_point");
String mapping = Strings.toString(xContentBuilder.field("store", true).endObject().endObject().endObject().endObject());
- DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser().parse("type", new CompressedXContent(mapping));
+ DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("type", new CompressedXContent(mapping));
- ParsedDocument doc = defaultMapper.parse(SourceToParse.source("test", "type", "1", BytesReference
- .bytes(XContentFactory.jsonBuilder()
+ ParsedDocument doc = defaultMapper.parse(SourceToParse.source("test", "type", "1",
+ BytesReference.bytes(XContentFactory.jsonBuilder()
.startObject()
.startArray("point").value(1.3).value(1.2).endArray()
.endObject()),
@@ -256,12 +262,14 @@ public void testLonLatArrayStored() throws Exception {
public void testLonLatArrayArrayStored() throws Exception {
XContentBuilder xContentBuilder = XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("properties").startObject("point").field("type", "geo_point");
- String mapping = Strings.toString(xContentBuilder.field("store", true).field("doc_values", false).endObject().endObject()
+ String mapping = Strings.toString(xContentBuilder.field("store", true)
+ .field("doc_values", false).endObject().endObject()
.endObject().endObject());
- DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser().parse("type", new CompressedXContent(mapping));
+ DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("type", new CompressedXContent(mapping));
- ParsedDocument doc = defaultMapper.parse(SourceToParse.source("test", "type", "1", BytesReference
- .bytes(XContentFactory.jsonBuilder()
+ ParsedDocument doc = defaultMapper.parse(SourceToParse.source("test", "type", "1",
+ BytesReference.bytes(XContentFactory.jsonBuilder()
.startObject()
.startArray("point")
.startArray().value(1.3).value(1.2).endArray()
@@ -311,7 +319,8 @@ public void testIgnoreZValue() throws IOException {
public void testMultiField() throws Exception {
int numDocs = randomIntBetween(10, 100);
- String mapping = Strings.toString(XContentFactory.jsonBuilder().startObject().startObject("pin").startObject("properties").startObject("location")
+ String mapping = Strings.toString(XContentFactory.jsonBuilder().startObject().startObject("pin")
+ .startObject("properties").startObject("location")
.field("type", "geo_point")
.startObject("fields")
.startObject("geohash").field("type", "keyword").endObject() // test geohash as keyword
@@ -326,13 +335,15 @@ public void testMultiField() throws Exception {
client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().execute().actionGet();
for (int i=0; i defaultMapper.parse(SourceToParse.source("test", "type", "1", BytesReference
- .bytes(XContentFactory.jsonBuilder()
+ () -> defaultMapper.parse(SourceToParse.source("test", "type", "1",
+ BytesReference.bytes(XContentFactory.jsonBuilder()
.startObject()
.field("location", "1234.333")
.endObject()),
diff --git a/server/src/test/java/org/elasticsearch/index/mapper/GeoShapeFieldMapperTests.java b/server/src/test/java/org/elasticsearch/index/mapper/GeoShapeFieldMapperTests.java
index 45609c1b0f031..51de034de0445 100644
--- a/server/src/test/java/org/elasticsearch/index/mapper/GeoShapeFieldMapperTests.java
+++ b/server/src/test/java/org/elasticsearch/index/mapper/GeoShapeFieldMapperTests.java
@@ -58,7 +58,8 @@ public void testDefaultConfiguration() throws IOException {
.endObject().endObject()
.endObject().endObject());
- DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser().parse("type1", new CompressedXContent(mapping));
+ DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("type1", new CompressedXContent(mapping));
Mapper fieldMapper = defaultMapper.mappers().getMapper("location");
assertThat(fieldMapper, instanceOf(GeoShapeFieldMapper.class));
@@ -82,7 +83,8 @@ public void testOrientationParsing() throws IOException {
.endObject().endObject()
.endObject().endObject());
- DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser().parse("type1", new CompressedXContent(mapping));
+ DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("type1", new CompressedXContent(mapping));
Mapper fieldMapper = defaultMapper.mappers().getMapper("location");
assertThat(fieldMapper, instanceOf(GeoShapeFieldMapper.class));
@@ -99,7 +101,8 @@ public void testOrientationParsing() throws IOException {
.endObject().endObject()
.endObject().endObject());
- defaultMapper = createIndex("test2").mapperService().documentMapperParser().parse("type1", new CompressedXContent(mapping));
+ defaultMapper = createIndex("test2").mapperService().documentMapperParser()
+ .parse("type1", new CompressedXContent(mapping));
fieldMapper = defaultMapper.mappers().getMapper("location");
assertThat(fieldMapper, instanceOf(GeoShapeFieldMapper.class));
@@ -120,7 +123,8 @@ public void testCoerceParsing() throws IOException {
.endObject().endObject()
.endObject().endObject());
- DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser().parse("type1", new CompressedXContent(mapping));
+ DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("type1", new CompressedXContent(mapping));
Mapper fieldMapper = defaultMapper.mappers().getMapper("location");
assertThat(fieldMapper, instanceOf(GeoShapeFieldMapper.class));
@@ -135,7 +139,8 @@ public void testCoerceParsing() throws IOException {
.endObject().endObject()
.endObject().endObject());
- defaultMapper = createIndex("test2").mapperService().documentMapperParser().parse("type1", new CompressedXContent(mapping));
+ defaultMapper = createIndex("test2").mapperService().documentMapperParser()
+ .parse("type1", new CompressedXContent(mapping));
fieldMapper = defaultMapper.mappers().getMapper("location");
assertThat(fieldMapper, instanceOf(GeoShapeFieldMapper.class));
@@ -171,7 +176,8 @@ public void testIgnoreZValue() throws IOException {
.endObject().endObject()
.endObject().endObject());
- defaultMapper = createIndex("test2").mapperService().documentMapperParser().parse("type1", new CompressedXContent(mapping));
+ defaultMapper = createIndex("test2").mapperService().documentMapperParser()
+ .parse("type1", new CompressedXContent(mapping));
fieldMapper = defaultMapper.mappers().getMapper("location");
assertThat(fieldMapper, instanceOf(GeoShapeFieldMapper.class));
@@ -190,7 +196,8 @@ public void testIgnoreMalformedParsing() throws IOException {
.endObject().endObject()
.endObject().endObject());
- DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser().parse("type1", new CompressedXContent(mapping));
+ DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("type1", new CompressedXContent(mapping));
Mapper fieldMapper = defaultMapper.mappers().getMapper("location");
assertThat(fieldMapper, instanceOf(GeoShapeFieldMapper.class));
@@ -205,7 +212,8 @@ public void testIgnoreMalformedParsing() throws IOException {
.endObject().endObject()
.endObject().endObject());
- defaultMapper = createIndex("test2").mapperService().documentMapperParser().parse("type1", new CompressedXContent(mapping));
+ defaultMapper = createIndex("test2").mapperService().documentMapperParser()
+ .parse("type1", new CompressedXContent(mapping));
fieldMapper = defaultMapper.mappers().getMapper("location");
assertThat(fieldMapper, instanceOf(GeoShapeFieldMapper.class));
@@ -224,7 +232,8 @@ public void testGeohashConfiguration() throws IOException {
.endObject().endObject()
.endObject().endObject());
- DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser().parse("type1", new CompressedXContent(mapping));
+ DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("type1", new CompressedXContent(mapping));
Mapper fieldMapper = defaultMapper.mappers().getMapper("location");
assertThat(fieldMapper, instanceOf(GeoShapeFieldMapper.class));
@@ -247,7 +256,8 @@ public void testQuadtreeConfiguration() throws IOException {
.endObject().endObject()
.endObject().endObject());
- DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser().parse("type1", new CompressedXContent(mapping));
+ DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("type1", new CompressedXContent(mapping));
Mapper fieldMapper = defaultMapper.mappers().getMapper("location");
assertThat(fieldMapper, instanceOf(GeoShapeFieldMapper.class));
@@ -394,7 +404,8 @@ public void testPointsOnlyOption() throws IOException {
.endObject().endObject()
.endObject().endObject());
- DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser().parse("type1", new CompressedXContent(mapping));
+ DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("type1", new CompressedXContent(mapping));
Mapper fieldMapper = defaultMapper.mappers().getMapper("location");
assertThat(fieldMapper, instanceOf(GeoShapeFieldMapper.class));
@@ -455,14 +466,19 @@ public void testLevelDefaults() throws IOException {
public void testGeoShapeMapperMerge() throws Exception {
String stage1Mapping = Strings.toString(XContentFactory.jsonBuilder().startObject().startObject("type").startObject("properties")
- .startObject("shape").field("type", "geo_shape").field("tree", "geohash").field("strategy", "recursive")
- .field("precision", "1m").field("tree_levels", 8).field("distance_error_pct", 0.01).field("orientation", "ccw")
+ .startObject("shape").field("type", "geo_shape").field("tree", "geohash")
+ .field("strategy", "recursive")
+ .field("precision", "1m").field("tree_levels", 8).field("distance_error_pct", 0.01)
+ .field("orientation", "ccw")
.endObject().endObject().endObject().endObject());
MapperService mapperService = createIndex("test").mapperService();
- DocumentMapper docMapper = mapperService.merge("type", new CompressedXContent(stage1Mapping), MapperService.MergeReason.MAPPING_UPDATE, false);
+ DocumentMapper docMapper = mapperService.merge("type", new CompressedXContent(stage1Mapping),
+ MapperService.MergeReason.MAPPING_UPDATE, false);
String stage2Mapping = Strings.toString(XContentFactory.jsonBuilder().startObject().startObject("type")
- .startObject("properties").startObject("shape").field("type", "geo_shape").field("tree", "quadtree")
- .field("strategy", "term").field("precision", "1km").field("tree_levels", 26).field("distance_error_pct", 26)
+ .startObject("properties").startObject("shape").field("type", "geo_shape")
+ .field("tree", "quadtree")
+ .field("strategy", "term").field("precision", "1km")
+ .field("tree_levels", 26).field("distance_error_pct", 26)
.field("orientation", "cw").endObject().endObject().endObject().endObject());
try {
mapperService.merge("type", new CompressedXContent(stage2Mapping), MapperService.MergeReason.MAPPING_UPDATE, false);
@@ -490,8 +506,10 @@ public void testGeoShapeMapperMerge() throws Exception {
// correct mapping
stage2Mapping = Strings.toString(XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("properties").startObject("shape").field("type", "geo_shape").field("precision", "1m")
- .field("tree_levels", 8).field("distance_error_pct", 0.001).field("orientation", "cw").endObject().endObject().endObject().endObject());
- docMapper = mapperService.merge("type", new CompressedXContent(stage2Mapping), MapperService.MergeReason.MAPPING_UPDATE, false);
+ .field("tree_levels", 8).field("distance_error_pct", 0.001)
+ .field("orientation", "cw").endObject().endObject().endObject().endObject());
+ docMapper = mapperService.merge("type", new CompressedXContent(stage2Mapping),
+ MapperService.MergeReason.MAPPING_UPDATE, false);
fieldMapper = docMapper.mappers().getMapper("shape");
assertThat(fieldMapper, instanceOf(GeoShapeFieldMapper.class));
@@ -599,7 +617,8 @@ public void testPointsOnlyDefaultsWithTermStrategy() throws IOException {
.endObject().endObject()
.endObject().endObject());
- DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser().parse("type1", new CompressedXContent(mapping));
+ DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("type1", new CompressedXContent(mapping));
Mapper fieldMapper = defaultMapper.mappers().getMapper("location");
assertThat(fieldMapper, instanceOf(GeoShapeFieldMapper.class));
diff --git a/server/src/test/java/org/elasticsearch/index/mapper/IdFieldMapperTests.java b/server/src/test/java/org/elasticsearch/index/mapper/IdFieldMapperTests.java
index 1926ab63222a0..03ab76f927d84 100644
--- a/server/src/test/java/org/elasticsearch/index/mapper/IdFieldMapperTests.java
+++ b/server/src/test/java/org/elasticsearch/index/mapper/IdFieldMapperTests.java
@@ -37,7 +37,8 @@ public class IdFieldMapperTests extends ESSingleNodeTestCase {
public void testIncludeInObjectNotAllowed() throws Exception {
String mapping = Strings.toString(XContentFactory.jsonBuilder().startObject().startObject("type").endObject().endObject());
- DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser().parse("type", new CompressedXContent(mapping));
+ DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("type", new CompressedXContent(mapping));
try {
docMapper.parse(SourceToParse.source("test", "type", "1", BytesReference.bytes(XContentFactory.jsonBuilder()
@@ -51,8 +52,10 @@ public void testIncludeInObjectNotAllowed() throws Exception {
public void testDefaultsSingleType() throws IOException {
Settings indexSettings = Settings.EMPTY;
MapperService mapperService = createIndex("test", indexSettings).mapperService();
- DocumentMapper mapper = mapperService.merge("type", new CompressedXContent("{\"type\":{}}"), MergeReason.MAPPING_UPDATE, false);
- ParsedDocument document = mapper.parse(SourceToParse.source("index", "type", "id", new BytesArray("{}"), XContentType.JSON));
+ DocumentMapper mapper = mapperService.merge("type", new CompressedXContent("{\"type\":{}}"),
+ MergeReason.MAPPING_UPDATE, false);
+ ParsedDocument document = mapper.parse(SourceToParse.source("index", "type", "id",
+ new BytesArray("{}"), XContentType.JSON));
IndexableField[] fields = document.rootDoc().getFields(IdFieldMapper.NAME);
assertEquals(1, fields.length);
assertEquals(IndexOptions.DOCS, fields[0].fieldType().indexOptions());
diff --git a/server/src/test/java/org/elasticsearch/index/mapper/IndexFieldMapperTests.java b/server/src/test/java/org/elasticsearch/index/mapper/IndexFieldMapperTests.java
index 5e60e248927d7..e60b097aaca36 100644
--- a/server/src/test/java/org/elasticsearch/index/mapper/IndexFieldMapperTests.java
+++ b/server/src/test/java/org/elasticsearch/index/mapper/IndexFieldMapperTests.java
@@ -44,10 +44,11 @@ protected Collection> getPlugins() {
public void testDefaultDisabledIndexMapper() throws Exception {
String mapping = Strings.toString(XContentFactory.jsonBuilder().startObject().startObject("type")
.endObject().endObject());
- DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser().parse("type", new CompressedXContent(mapping));
+ DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("type", new CompressedXContent(mapping));
- ParsedDocument doc = docMapper.parse(SourceToParse.source("test", "type", "1", BytesReference
- .bytes(XContentFactory.jsonBuilder()
+ ParsedDocument doc = docMapper.parse(SourceToParse.source("test", "type", "1",
+ BytesReference.bytes(XContentFactory.jsonBuilder()
.startObject()
.field("field", "value")
.endObject()),
diff --git a/server/src/test/java/org/elasticsearch/index/mapper/MapperServiceTests.java b/server/src/test/java/org/elasticsearch/index/mapper/MapperServiceTests.java
index 5594cae2d1ef8..76198eaaacf37 100644
--- a/server/src/test/java/org/elasticsearch/index/mapper/MapperServiceTests.java
+++ b/server/src/test/java/org/elasticsearch/index/mapper/MapperServiceTests.java
@@ -35,7 +35,6 @@
import org.elasticsearch.index.mapper.NumberFieldMapper.NumberFieldType;
import org.elasticsearch.indices.InvalidTypeNameException;
import org.elasticsearch.test.ESSingleNodeTestCase;
-import org.hamcrest.Matchers;
import java.io.IOException;
import java.util.HashMap;
@@ -76,7 +75,8 @@ public void testTypeNameTooLong() {
.addMapping(type, field, "type=text")
.execute().actionGet();
});
- assertTrue(e.getMessage(), e.getMessage().contains("mapping type name [" + type + "] is too long; limit is length 255 but was [256]"));
+ assertTrue(e.getMessage(), e.getMessage().contains("mapping type name [" + type
+ + "] is too long; limit is length 255 but was [256]"));
}
public void testTypeValidation() {
@@ -91,9 +91,9 @@ public void testTypeValidation() {
public void testIndexIntoDefaultMapping() throws Throwable {
// 1. test implicit index creation
- ExecutionException e = expectThrows(ExecutionException.class, () -> {
- client().prepareIndex("index1", MapperService.DEFAULT_MAPPING, "1").setSource("{}", XContentType.JSON).execute().get();
- });
+ ExecutionException e = expectThrows(ExecutionException.class,
+ () -> client().prepareIndex("index1", MapperService.DEFAULT_MAPPING, "1")
+ .setSource("{}", XContentType.JSON).execute().get());
Throwable throwable = ExceptionsHelper.unwrapCause(e.getCause());
if (throwable instanceof IllegalArgumentException) {
assertEquals("It is forbidden to index into the default mapping [_default_]", throwable.getMessage());
@@ -122,14 +122,15 @@ public void testIndexIntoDefaultMapping() throws Throwable {
*/
public void testTotalFieldsLimit() throws Throwable {
int totalFieldsLimit = randomIntBetween(1, 10);
- Settings settings = Settings.builder().put(MapperService.INDEX_MAPPING_TOTAL_FIELDS_LIMIT_SETTING.getKey(), totalFieldsLimit).build();
+ Settings settings = Settings.builder().put(MapperService.INDEX_MAPPING_TOTAL_FIELDS_LIMIT_SETTING.getKey(), totalFieldsLimit)
+ .build();
createIndex("test1", settings).mapperService().merge("type", createMappingSpecifyingNumberOfFields(totalFieldsLimit),
MergeReason.MAPPING_UPDATE, false);
// adding one more field should trigger exception
IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> {
- createIndex("test2", settings).mapperService().merge("type", createMappingSpecifyingNumberOfFields(totalFieldsLimit + 1),
- MergeReason.MAPPING_UPDATE, false);
+ createIndex("test2", settings).mapperService().merge("type",
+ createMappingSpecifyingNumberOfFields(totalFieldsLimit + 1), MergeReason.MAPPING_UPDATE, false);
});
assertTrue(e.getMessage(),
e.getMessage().contains("Limit of total fields [" + totalFieldsLimit + "] in index [test2] has been exceeded"));
@@ -151,7 +152,8 @@ public void testMappingDepthExceedsLimit() throws Throwable {
IndexService indexService1 = createIndex("test1",
Settings.builder().put(MapperService.INDEX_MAPPING_DEPTH_LIMIT_SETTING.getKey(), 1).build());
// no exception
- indexService1.mapperService().merge("type", createMappingSpecifyingNumberOfFields(1), MergeReason.MAPPING_UPDATE, false);
+ indexService1.mapperService().merge("type", createMappingSpecifyingNumberOfFields(1),
+ MergeReason.MAPPING_UPDATE, false);
CompressedXContent objectMapping = new CompressedXContent(BytesReference.bytes(XContentFactory.jsonBuilder().startObject()
.startObject("properties")
@@ -344,7 +346,8 @@ public void testTotalFieldsLimitWithFieldAlias() throws Throwable {
IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> {
createIndex("test2",
Settings.builder().put(MapperService.INDEX_MAPPING_TOTAL_FIELDS_LIMIT_SETTING.getKey(), numberOfNonAliasFields).build())
- .mapperService().merge("type", new CompressedXContent(mapping), MergeReason.MAPPING_UPDATE, true);
+ .mapperService().merge("type", new CompressedXContent(mapping),
+ MergeReason.MAPPING_UPDATE, true);
});
assertEquals("Limit of total fields [" + numberOfNonAliasFields + "] in index [test2] has been exceeded", e.getMessage());
}
@@ -357,7 +360,7 @@ public void testForbidMultipleTypes() throws IOException {
String mapping2 = Strings.toString(XContentFactory.jsonBuilder().startObject().startObject("type2").endObject().endObject());
IllegalArgumentException e = expectThrows(IllegalArgumentException.class,
() -> mapperService.merge("type2", new CompressedXContent(mapping2), MergeReason.MAPPING_UPDATE, randomBoolean()));
- assertThat(e.getMessage(), Matchers.startsWith("Rejecting mapping update to [test] as the final mapping would have more than 1 type: "));
+ assertThat(e.getMessage(), startsWith("Rejecting mapping update to [test] as the final mapping would have more than 1 type: "));
}
/**
@@ -366,15 +369,17 @@ public void testForbidMultipleTypes() throws IOException {
*/
public void testForbidMultipleTypesWithConflictingMappings() throws IOException {
String mapping = Strings.toString(XContentFactory.jsonBuilder().startObject().startObject("type")
- .startObject("properties").startObject("field1").field("type", "integer_range").endObject().endObject().endObject().endObject());
+ .startObject("properties").startObject("field1").field("type", "integer_range")
+ .endObject().endObject().endObject().endObject());
MapperService mapperService = createIndex("test").mapperService();
mapperService.merge("type", new CompressedXContent(mapping), MergeReason.MAPPING_UPDATE, false);
String mapping2 = Strings.toString(XContentFactory.jsonBuilder().startObject().startObject("type2")
- .startObject("properties").startObject("field1").field("type", "integer").endObject().endObject().endObject().endObject());
+ .startObject("properties").startObject("field1").field("type", "integer")
+ .endObject().endObject().endObject().endObject());
IllegalArgumentException e = expectThrows(IllegalArgumentException.class,
() -> mapperService.merge("type2", new CompressedXContent(mapping2), MergeReason.MAPPING_UPDATE, false));
- assertThat(e.getMessage(), Matchers.startsWith("Rejecting mapping update to [test] as the final mapping would have more than 1 type: "));
+ assertThat(e.getMessage(), startsWith("Rejecting mapping update to [test] as the final mapping would have more than 1 type: "));
}
public void testDefaultMappingIsDeprecated() throws IOException {
diff --git a/server/src/test/java/org/elasticsearch/index/mapper/MultiFieldCopyToMapperTests.java b/server/src/test/java/org/elasticsearch/index/mapper/MultiFieldCopyToMapperTests.java
index b17abcc17b359..6ecf4b6408be3 100644
--- a/server/src/test/java/org/elasticsearch/index/mapper/MultiFieldCopyToMapperTests.java
+++ b/server/src/test/java/org/elasticsearch/index/mapper/MultiFieldCopyToMapperTests.java
@@ -43,7 +43,8 @@ public void testExceptionForCopyToInMultiFields() throws IOException {
mapperService.parse("type", new CompressedXContent(Strings.toString(mapping)), true);
fail("Parsing should throw an exception because the mapping contains a copy_to in a multi field");
} catch (MapperParsingException e) {
- assertThat(e.getMessage(), equalTo("copy_to in multi fields is not allowed. Found the copy_to in field [c] which is within a multi field."));
+ assertThat(e.getMessage(), equalTo("copy_to in multi fields is not allowed. Found the copy_to in field [c]"
+ + " which is within a multi field."));
}
}
diff --git a/server/src/test/java/org/elasticsearch/index/mapper/MultiFieldTests.java b/server/src/test/java/org/elasticsearch/index/mapper/MultiFieldTests.java
index da9e84cfcf4d7..ce04ff6489059 100644
--- a/server/src/test/java/org/elasticsearch/index/mapper/MultiFieldTests.java
+++ b/server/src/test/java/org/elasticsearch/index/mapper/MultiFieldTests.java
@@ -133,7 +133,8 @@ public void testBuildThenParse() throws Exception {
String builtMapping = builderDocMapper.mappingSource().string();
// reparse it
- DocumentMapper docMapper = indexService.mapperService().documentMapperParser().parse("person", new CompressedXContent(builtMapping));
+ DocumentMapper docMapper = indexService.mapperService().documentMapperParser()
+ .parse("person", new CompressedXContent(builtMapping));
BytesReference json = new BytesArray(copyToBytesFromClasspath("/org/elasticsearch/index/mapper/multifield/test-data.json"));
@@ -174,13 +175,15 @@ public void testMultiFieldsInConsistentOrder() throws Exception {
}
builder = builder.endObject().endObject().endObject().endObject().endObject();
String mapping = Strings.toString(builder);
- DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser().parse("type", new CompressedXContent(mapping));
+ DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("type", new CompressedXContent(mapping));
Arrays.sort(multiFieldNames);
Map sourceAsMap =
XContentHelper.convertToMap(docMapper.mappingSource().compressedReference(), true, builder.contentType()).v2();
@SuppressWarnings("unchecked")
- Map multiFields = (Map) XContentMapValues.extractValue("type.properties.my_field.fields", sourceAsMap);
+ Map multiFields =
+ (Map) XContentMapValues.extractValue("type.properties.my_field.fields", sourceAsMap);
assertThat(multiFields.size(), equalTo(multiFieldNames.length));
int i = 0;
@@ -192,7 +195,8 @@ public void testMultiFieldsInConsistentOrder() throws Exception {
public void testObjectFieldNotAllowed() throws Exception {
String mapping = Strings.toString(jsonBuilder().startObject().startObject("type").startObject("properties").startObject("my_field")
- .field("type", "text").startObject("fields").startObject("multi").field("type", "object").endObject().endObject()
+ .field("type", "text").startObject("fields").startObject("multi").field("type", "object")
+ .endObject().endObject()
.endObject().endObject().endObject().endObject());
final DocumentMapperParser parser = createIndex("test").mapperService().documentMapperParser();
try {
@@ -205,7 +209,8 @@ public void testObjectFieldNotAllowed() throws Exception {
public void testNestedFieldNotAllowed() throws Exception {
String mapping = Strings.toString(jsonBuilder().startObject().startObject("type").startObject("properties").startObject("my_field")
- .field("type", "text").startObject("fields").startObject("multi").field("type", "nested").endObject().endObject()
+ .field("type", "text").startObject("fields").startObject("multi").field("type", "nested")
+ .endObject().endObject()
.endObject().endObject().endObject().endObject());
final DocumentMapperParser parser = createIndex("test").mapperService().documentMapperParser();
try {
diff --git a/server/src/test/java/org/elasticsearch/index/mapper/NestedObjectMapperTests.java b/server/src/test/java/org/elasticsearch/index/mapper/NestedObjectMapperTests.java
index d590709d729a0..400426ee5710a 100644
--- a/server/src/test/java/org/elasticsearch/index/mapper/NestedObjectMapperTests.java
+++ b/server/src/test/java/org/elasticsearch/index/mapper/NestedObjectMapperTests.java
@@ -51,7 +51,8 @@ public void testEmptyNested() throws Exception {
.startObject("nested1").field("type", "nested").endObject()
.endObject().endObject().endObject());
- DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser().parse("type", new CompressedXContent(mapping));
+ DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("type", new CompressedXContent(mapping));
ParsedDocument doc = docMapper.parse(SourceToParse.source("test", "type", "1", BytesReference
.bytes(XContentFactory.jsonBuilder()
@@ -79,7 +80,8 @@ public void testSingleNested() throws Exception {
.startObject("nested1").field("type", "nested").endObject()
.endObject().endObject().endObject());
- DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser().parse("type", new CompressedXContent(mapping));
+ DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("type", new CompressedXContent(mapping));
assertThat(docMapper.hasNestedObjects(), equalTo(true));
ObjectMapper nested1Mapper = docMapper.objectMappers().get("nested1");
@@ -130,7 +132,8 @@ public void testMultiNested() throws Exception {
.endObject().endObject().endObject()
.endObject().endObject().endObject());
- DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser().parse("type", new CompressedXContent(mapping));
+ DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("type", new CompressedXContent(mapping));
assertThat(docMapper.hasNestedObjects(), equalTo(true));
ObjectMapper nested1Mapper = docMapper.objectMappers().get("nested1");
@@ -142,13 +145,21 @@ public void testMultiNested() throws Exception {
assertThat(nested2Mapper.nested().isIncludeInParent(), equalTo(false));
assertThat(nested2Mapper.nested().isIncludeInRoot(), equalTo(false));
- ParsedDocument doc = docMapper.parse(SourceToParse.source("test", "type", "1", BytesReference
- .bytes(XContentFactory.jsonBuilder()
+ ParsedDocument doc = docMapper.parse(SourceToParse.source("test", "type", "1",
+ BytesReference.bytes(XContentFactory.jsonBuilder()
.startObject()
.field("field", "value")
.startArray("nested1")
- .startObject().field("field1", "1").startArray("nested2").startObject().field("field2", "2").endObject().startObject().field("field2", "3").endObject().endArray().endObject()
- .startObject().field("field1", "4").startArray("nested2").startObject().field("field2", "5").endObject().startObject().field("field2", "6").endObject().endArray().endObject()
+ .startObject().field("field1", "1").startArray("nested2")
+ .startObject().field("field2", "2").endObject()
+ .startObject().field("field2", "3").endObject()
+ .endArray()
+ .endObject()
+ .startObject().field("field1", "4")
+ .startArray("nested2")
+ .startObject().field("field2", "5").endObject()
+ .startObject().field("field2", "6").endObject()
+ .endArray().endObject()
.endArray()
.endObject()),
XContentType.JSON));
@@ -182,7 +193,8 @@ public void testMultiObjectAndNested1() throws Exception {
.endObject().endObject().endObject()
.endObject().endObject().endObject());
- DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser().parse("type", new CompressedXContent(mapping));
+ DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("type", new CompressedXContent(mapping));
assertThat(docMapper.hasNestedObjects(), equalTo(true));
ObjectMapper nested1Mapper = docMapper.objectMappers().get("nested1");
@@ -194,13 +206,21 @@ public void testMultiObjectAndNested1() throws Exception {
assertThat(nested2Mapper.nested().isIncludeInParent(), equalTo(true));
assertThat(nested2Mapper.nested().isIncludeInRoot(), equalTo(false));
- ParsedDocument doc = docMapper.parse(SourceToParse.source("test", "type", "1", BytesReference
- .bytes(XContentFactory.jsonBuilder()
+ ParsedDocument doc = docMapper.parse(SourceToParse.source("test", "type", "1",
+ BytesReference.bytes(XContentFactory.jsonBuilder()
.startObject()
.field("field", "value")
.startArray("nested1")
- .startObject().field("field1", "1").startArray("nested2").startObject().field("field2", "2").endObject().startObject().field("field2", "3").endObject().endArray().endObject()
- .startObject().field("field1", "4").startArray("nested2").startObject().field("field2", "5").endObject().startObject().field("field2", "6").endObject().endArray().endObject()
+ .startObject().field("field1", "1")
+ .startArray("nested2")
+ .startObject().field("field2", "2").endObject()
+ .startObject().field("field2", "3").endObject()
+ .endArray().endObject()
+ .startObject().field("field1", "4")
+ .startArray("nested2")
+ .startObject().field("field2", "5").endObject()
+ .startObject().field("field2", "6").endObject()
+ .endArray().endObject()
.endArray()
.endObject()),
XContentType.JSON));
@@ -228,13 +248,16 @@ public void testMultiObjectAndNested1() throws Exception {
}
public void testMultiObjectAndNested2() throws Exception {
- String mapping = Strings.toString(XContentFactory.jsonBuilder().startObject().startObject("type").startObject("properties")
- .startObject("nested1").field("type", "nested").field("include_in_parent", true).startObject("properties")
+ String mapping = Strings.toString(XContentFactory.jsonBuilder().startObject().startObject("type")
+ .startObject("properties")
+ .startObject("nested1").field("type", "nested").field("include_in_parent", true)
+ .startObject("properties")
.startObject("nested2").field("type", "nested").field("include_in_parent", true)
.endObject().endObject().endObject()
.endObject().endObject().endObject());
- DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser().parse("type", new CompressedXContent(mapping));
+ DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("type", new CompressedXContent(mapping));
assertThat(docMapper.hasNestedObjects(), equalTo(true));
ObjectMapper nested1Mapper = docMapper.objectMappers().get("nested1");
@@ -246,13 +269,21 @@ public void testMultiObjectAndNested2() throws Exception {
assertThat(nested2Mapper.nested().isIncludeInParent(), equalTo(true));
assertThat(nested2Mapper.nested().isIncludeInRoot(), equalTo(false));
- ParsedDocument doc = docMapper.parse(SourceToParse.source("test", "type", "1", BytesReference
- .bytes(XContentFactory.jsonBuilder()
+ ParsedDocument doc = docMapper.parse(SourceToParse.source("test", "type", "1",
+ BytesReference.bytes(XContentFactory.jsonBuilder()
.startObject()
.field("field", "value")
.startArray("nested1")
- .startObject().field("field1", "1").startArray("nested2").startObject().field("field2", "2").endObject().startObject().field("field2", "3").endObject().endArray().endObject()
- .startObject().field("field1", "4").startArray("nested2").startObject().field("field2", "5").endObject().startObject().field("field2", "6").endObject().endArray().endObject()
+ .startObject().field("field1", "1")
+ .startArray("nested2")
+ .startObject().field("field2", "2").endObject()
+ .startObject().field("field2", "3").endObject()
+ .endArray().endObject()
+ .startObject().field("field1", "4")
+ .startArray("nested2")
+ .startObject().field("field2", "5").endObject()
+ .startObject().field("field2", "6").endObject()
+ .endArray().endObject()
.endArray()
.endObject()),
XContentType.JSON));
@@ -286,7 +317,8 @@ public void testMultiRootAndNested1() throws Exception {
.endObject().endObject().endObject()
.endObject().endObject().endObject());
- DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser().parse("type", new CompressedXContent(mapping));
+ DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("type", new CompressedXContent(mapping));
assertThat(docMapper.hasNestedObjects(), equalTo(true));
ObjectMapper nested1Mapper = docMapper.objectMappers().get("nested1");
@@ -298,13 +330,21 @@ public void testMultiRootAndNested1() throws Exception {
assertThat(nested2Mapper.nested().isIncludeInParent(), equalTo(false));
assertThat(nested2Mapper.nested().isIncludeInRoot(), equalTo(true));
- ParsedDocument doc = docMapper.parse(SourceToParse.source("test", "type", "1", BytesReference
- .bytes(XContentFactory.jsonBuilder()
+ ParsedDocument doc = docMapper.parse(SourceToParse.source("test", "type", "1",
+ BytesReference.bytes(XContentFactory.jsonBuilder()
.startObject()
.field("field", "value")
.startArray("nested1")
- .startObject().field("field1", "1").startArray("nested2").startObject().field("field2", "2").endObject().startObject().field("field2", "3").endObject().endArray().endObject()
- .startObject().field("field1", "4").startArray("nested2").startObject().field("field2", "5").endObject().startObject().field("field2", "6").endObject().endArray().endObject()
+ .startObject().field("field1", "1")
+ .startArray("nested2")
+ .startObject().field("field2", "2").endObject()
+ .startObject().field("field2", "3").endObject()
+ .endArray().endObject()
+ .startObject().field("field1", "4")
+ .startArray("nested2")
+ .startObject().field("field2", "5").endObject()
+ .startObject().field("field2", "6").endObject()
+ .endArray().endObject()
.endArray()
.endObject()),
XContentType.JSON));
@@ -339,15 +379,18 @@ public void testMultiRootAndNested1() throws Exception {
public void testMultipleLevelsIncludeRoot1() throws Exception {
String mapping = Strings.toString(XContentFactory.jsonBuilder()
.startObject().startObject("type").startObject("properties")
- .startObject("nested1").field("type", "nested").field("include_in_root", true).field("include_in_parent", true).startObject("properties")
- .startObject("nested2").field("type", "nested").field("include_in_root", true).field("include_in_parent", true)
+ .startObject("nested1").field("type", "nested").field("include_in_root", true)
+ .field("include_in_parent", true).startObject("properties")
+ .startObject("nested2").field("type", "nested").field("include_in_root", true)
+ .field("include_in_parent", true)
.endObject().endObject().endObject()
.endObject().endObject().endObject());
- DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser().parse("type", new CompressedXContent(mapping));
+ DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("type", new CompressedXContent(mapping));
- ParsedDocument doc = docMapper.parse(SourceToParse.source("test", "type", "1", BytesReference
- .bytes(XContentFactory.jsonBuilder()
+ ParsedDocument doc = docMapper.parse(SourceToParse.source("test", "type", "1",
+ BytesReference.bytes(XContentFactory.jsonBuilder()
.startObject().startArray("nested1")
.startObject().startArray("nested2").startObject().field("foo", "bar")
.endObject().endArray().endObject().endArray()
@@ -377,10 +420,11 @@ public void testMultipleLevelsIncludeRoot2() throws Exception {
.endObject().endObject().endObject().endObject().endObject()
.endObject().endObject().endObject());
- DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser().parse("type", new CompressedXContent(mapping));
+ DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("type", new CompressedXContent(mapping));
- ParsedDocument doc = docMapper.parse(SourceToParse.source("test", "type", "1", BytesReference
- .bytes(XContentFactory.jsonBuilder()
+ ParsedDocument doc = docMapper.parse(SourceToParse.source("test", "type", "1",
+ BytesReference.bytes(XContentFactory.jsonBuilder()
.startObject().startArray("nested1")
.startObject().startArray("nested2")
.startObject().startArray("nested3").startObject().field("foo", "bar")
@@ -399,15 +443,16 @@ public void testNestedArrayStrict() throws Exception {
.endObject().endObject().endObject()
.endObject().endObject().endObject());
- DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser().parse("type", new CompressedXContent(mapping));
+ DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("type", new CompressedXContent(mapping));
assertThat(docMapper.hasNestedObjects(), equalTo(true));
ObjectMapper nested1Mapper = docMapper.objectMappers().get("nested1");
assertThat(nested1Mapper.nested().isNested(), equalTo(true));
assertThat(nested1Mapper.dynamic(), equalTo(Dynamic.STRICT));
- ParsedDocument doc = docMapper.parse(SourceToParse.source("test", "type", "1", BytesReference
- .bytes(XContentFactory.jsonBuilder()
+ ParsedDocument doc = docMapper.parse(SourceToParse.source("test", "type", "1",
+ BytesReference.bytes(XContentFactory.jsonBuilder()
.startObject()
.field("field", "value")
.startArray("nested1")
@@ -439,23 +484,30 @@ public void testLimitOfNestedFieldsPerIndex() throws Exception {
};
// default limit allows at least two nested fields
- createIndex("test1").mapperService().merge("type", new CompressedXContent(mapping.apply("type")), MergeReason.MAPPING_UPDATE, false);
+ createIndex("test1").mapperService().merge("type", new CompressedXContent(mapping.apply("type")),
+ MergeReason.MAPPING_UPDATE, false);
// explicitly setting limit to 0 prevents nested fields
Exception e = expectThrows(IllegalArgumentException.class, () ->
- createIndex("test2", Settings.builder().put(MapperService.INDEX_MAPPING_NESTED_FIELDS_LIMIT_SETTING.getKey(), 0).build())
- .mapperService().merge("type", new CompressedXContent(mapping.apply("type")), MergeReason.MAPPING_UPDATE, false));
+ createIndex("test2", Settings.builder().put(MapperService.INDEX_MAPPING_NESTED_FIELDS_LIMIT_SETTING.getKey(), 0)
+ .build())
+ .mapperService().merge("type", new CompressedXContent(mapping.apply("type")),
+ MergeReason.MAPPING_UPDATE, false));
assertThat(e.getMessage(), containsString("Limit of nested fields [0] in index [test2] has been exceeded"));
// setting limit to 1 with 2 nested fields fails
e = expectThrows(IllegalArgumentException.class, () ->
- createIndex("test3", Settings.builder().put(MapperService.INDEX_MAPPING_NESTED_FIELDS_LIMIT_SETTING.getKey(), 1).build())
- .mapperService().merge("type", new CompressedXContent(mapping.apply("type")), MergeReason.MAPPING_UPDATE, false));
+ createIndex("test3", Settings.builder().put(MapperService.INDEX_MAPPING_NESTED_FIELDS_LIMIT_SETTING.getKey(), 1)
+ .build())
+ .mapperService().merge("type", new CompressedXContent(mapping.apply("type")),
+ MergeReason.MAPPING_UPDATE, false));
assertThat(e.getMessage(), containsString("Limit of nested fields [1] in index [test3] has been exceeded"));
// do not check nested fields limit if mapping is not updated
- createIndex("test4", Settings.builder().put(MapperService.INDEX_MAPPING_NESTED_FIELDS_LIMIT_SETTING.getKey(), 0).build())
- .mapperService().merge("type", new CompressedXContent(mapping.apply("type")), MergeReason.MAPPING_RECOVERY, false);
+ createIndex("test4", Settings.builder().put(MapperService.INDEX_MAPPING_NESTED_FIELDS_LIMIT_SETTING.getKey(), 0)
+ .build())
+ .mapperService().merge("type", new CompressedXContent(mapping.apply("type")),
+ MergeReason.MAPPING_RECOVERY, false);
}
public void testParentObjectMapperAreNested() throws Exception {
@@ -511,8 +563,8 @@ public void testReorderParentBWC() throws IOException {
ObjectMapper nested1Mapper = docMapper.objectMappers().get("nested1");
assertThat(nested1Mapper.nested().isNested(), equalTo(true));
- ParsedDocument doc = docMapper.parse(SourceToParse.source("test", "type", "1", BytesReference
- .bytes(XContentFactory.jsonBuilder()
+ ParsedDocument doc = docMapper.parse(SourceToParse.source("test", "type", "1",
+ BytesReference.bytes(XContentFactory.jsonBuilder()
.startObject()
.field("field", "value")
.startArray("nested1")
diff --git a/server/src/test/java/org/elasticsearch/index/mapper/NullValueObjectMappingTests.java b/server/src/test/java/org/elasticsearch/index/mapper/NullValueObjectMappingTests.java
index 815388eeffc55..550802f6c9dfd 100644
--- a/server/src/test/java/org/elasticsearch/index/mapper/NullValueObjectMappingTests.java
+++ b/server/src/test/java/org/elasticsearch/index/mapper/NullValueObjectMappingTests.java
@@ -36,10 +36,11 @@ public void testNullValueObject() throws IOException {
.startObject("properties").startObject("obj1").field("type", "object").endObject().endObject()
.endObject().endObject());
- DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser().parse("type", new CompressedXContent(mapping));
+ DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("type", new CompressedXContent(mapping));
- ParsedDocument doc = defaultMapper.parse(SourceToParse.source("test", "type", "1", BytesReference
- .bytes(XContentFactory.jsonBuilder()
+ ParsedDocument doc = defaultMapper.parse(SourceToParse.source("test", "type", "1",
+ BytesReference.bytes(XContentFactory.jsonBuilder()
.startObject()
.startObject("obj1").endObject()
.field("value1", "test1")
@@ -48,8 +49,8 @@ public void testNullValueObject() throws IOException {
assertThat(doc.rootDoc().get("value1"), equalTo("test1"));
- doc = defaultMapper.parse(SourceToParse.source("test", "type", "1", BytesReference
- .bytes(XContentFactory.jsonBuilder()
+ doc = defaultMapper.parse(SourceToParse.source("test", "type", "1",
+ BytesReference.bytes(XContentFactory.jsonBuilder()
.startObject()
.nullField("obj1")
.field("value1", "test1")
@@ -58,8 +59,8 @@ public void testNullValueObject() throws IOException {
assertThat(doc.rootDoc().get("value1"), equalTo("test1"));
- doc = defaultMapper.parse(SourceToParse.source("test", "type", "1", BytesReference
- .bytes(XContentFactory.jsonBuilder()
+ doc = defaultMapper.parse(SourceToParse.source("test", "type", "1",
+ BytesReference.bytes(XContentFactory.jsonBuilder()
.startObject()
.startObject("obj1").field("field", "value").endObject()
.field("value1", "test1")
diff --git a/server/src/test/java/org/elasticsearch/index/mapper/ObjectMapperTests.java b/server/src/test/java/org/elasticsearch/index/mapper/ObjectMapperTests.java
index 0df6f7a4fb78d..6a35e15ad867e 100644
--- a/server/src/test/java/org/elasticsearch/index/mapper/ObjectMapperTests.java
+++ b/server/src/test/java/org/elasticsearch/index/mapper/ObjectMapperTests.java
@@ -40,7 +40,8 @@ public void testDifferentInnerObjectTokenFailure() throws Exception {
String mapping = Strings.toString(XContentFactory.jsonBuilder().startObject().startObject("type")
.endObject().endObject());
- DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser().parse("type", new CompressedXContent(mapping));
+ DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("type", new CompressedXContent(mapping));
IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> {
defaultMapper.parse(SourceToParse.source("test", "type", "1", new BytesArray(" {\n" +
" \"object\": {\n" +
@@ -68,38 +69,37 @@ public void testEmptyArrayProperties() throws Exception {
}
public void testEmptyFieldsArrayMultiFields() throws Exception {
- String mapping = Strings
- .toString(XContentFactory.jsonBuilder()
- .startObject()
- .startObject("tweet")
- .startObject("properties")
- .startObject("name")
- .field("type", "text")
- .startArray("fields")
- .endArray()
- .endObject()
- .endObject()
- .endObject()
- .endObject());
+ String mapping =
+ Strings.toString(XContentFactory.jsonBuilder()
+ .startObject()
+ .startObject("tweet")
+ .startObject("properties")
+ .startObject("name")
+ .field("type", "text")
+ .startArray("fields")
+ .endArray()
+ .endObject()
+ .endObject()
+ .endObject()
+ .endObject());
createIndex("test").mapperService().documentMapperParser().parse("tweet", new CompressedXContent(mapping));
}
public void testFieldsArrayMultiFieldsShouldThrowException() throws Exception {
- String mapping = Strings
- .toString(XContentFactory.jsonBuilder()
- .startObject()
- .startObject("tweet")
- .startObject("properties")
- .startObject("name")
- .field("type", "text")
- .startArray("fields")
- .startObject().field("test", "string").endObject()
- .startObject().field("test2", "string").endObject()
- .endArray()
- .endObject()
- .endObject()
+ String mapping = Strings.toString(XContentFactory.jsonBuilder()
+ .startObject()
+ .startObject("tweet")
+ .startObject("properties")
+ .startObject("name")
+ .field("type", "text")
+ .startArray("fields")
+ .startObject().field("test", "string").endObject()
+ .startObject().field("test2", "string").endObject()
+ .endArray()
.endObject()
- .endObject());
+ .endObject()
+ .endObject()
+ .endObject());
try {
createIndex("test").mapperService().documentMapperParser().parse("tweet", new CompressedXContent(mapping));
fail("Expected MapperParsingException");
@@ -110,32 +110,30 @@ public void testFieldsArrayMultiFieldsShouldThrowException() throws Exception {
}
public void testEmptyFieldsArray() throws Exception {
- String mapping = Strings
- .toString(XContentFactory.jsonBuilder()
- .startObject()
- .startObject("tweet")
- .startObject("properties")
- .startArray("fields")
- .endArray()
- .endObject()
- .endObject()
- .endObject());
+ String mapping = Strings.toString(XContentFactory.jsonBuilder()
+ .startObject()
+ .startObject("tweet")
+ .startObject("properties")
+ .startArray("fields")
+ .endArray()
+ .endObject()
+ .endObject()
+ .endObject());
createIndex("test").mapperService().documentMapperParser().parse("tweet", new CompressedXContent(mapping));
}
public void testFieldsWithFilledArrayShouldThrowException() throws Exception {
- String mapping = Strings
- .toString(XContentFactory.jsonBuilder()
- .startObject()
- .startObject("tweet")
- .startObject("properties")
- .startArray("fields")
- .startObject().field("test", "string").endObject()
- .startObject().field("test2", "string").endObject()
- .endArray()
- .endObject()
- .endObject()
- .endObject());
+ String mapping = Strings.toString(XContentFactory.jsonBuilder()
+ .startObject()
+ .startObject("tweet")
+ .startObject("properties")
+ .startArray("fields")
+ .startObject().field("test", "string").endObject()
+ .startObject().field("test2", "string").endObject()
+ .endArray()
+ .endObject()
+ .endObject()
+ .endObject());
try {
createIndex("test").mapperService().documentMapperParser().parse("tweet", new CompressedXContent(mapping));
fail("Expected MapperParsingException");
@@ -145,22 +143,21 @@ public void testFieldsWithFilledArrayShouldThrowException() throws Exception {
}
public void testFieldPropertiesArray() throws Exception {
- String mapping = Strings
- .toString(XContentFactory.jsonBuilder()
- .startObject()
- .startObject("tweet")
- .startObject("properties")
- .startObject("name")
- .field("type", "text")
- .startObject("fields")
- .startObject("raw")
- .field("type", "keyword")
- .endObject()
- .endObject()
- .endObject()
- .endObject()
- .endObject()
- .endObject());
+ String mapping = Strings.toString(XContentFactory.jsonBuilder()
+ .startObject()
+ .startObject("tweet")
+ .startObject("properties")
+ .startObject("name")
+ .field("type", "text")
+ .startObject("fields")
+ .startObject("raw")
+ .field("type", "keyword")
+ .endObject()
+ .endObject()
+ .endObject()
+ .endObject()
+ .endObject()
+ .endObject());
createIndex("test").mapperService().documentMapperParser().parse("tweet", new CompressedXContent(mapping));
}
@@ -188,7 +185,8 @@ public void testMerge() throws IOException {
}
public void testEmptyName() throws Exception {
- String mapping = Strings.toString(XContentFactory.jsonBuilder().startObject()
+ String mapping = Strings.toString(XContentFactory.jsonBuilder()
+ .startObject()
.startObject("")
.startObject("properties")
.startObject("name")
diff --git a/server/src/test/java/org/elasticsearch/index/mapper/ParentFieldMapperTests.java b/server/src/test/java/org/elasticsearch/index/mapper/ParentFieldMapperTests.java
index aa9589d70dca0..4b641023d56ec 100644
--- a/server/src/test/java/org/elasticsearch/index/mapper/ParentFieldMapperTests.java
+++ b/server/src/test/java/org/elasticsearch/index/mapper/ParentFieldMapperTests.java
@@ -64,7 +64,8 @@ public void testParentSetInDocNotAllowed() throws Exception {
.startObject().field("_parent", "1122").endObject()), XContentType.JSON));
fail("Expected failure to parse metadata field");
} catch (MapperParsingException e) {
- assertTrue(e.getMessage(), e.getMessage().contains("Field [_parent] is a metadata field and cannot be added inside a document"));
+ assertThat(e.getMessage(), e.getMessage(),
+ containsString("Field [_parent] is a metadata field and cannot be added inside a document"));
}
}
@@ -94,7 +95,8 @@ public void testNoParentNullFieldCreatedIfNoParentSpecified() throws Exception {
.startObject("properties")
.endObject()
.endObject().endObject();
- mapperService.merge("some_type", new CompressedXContent(Strings.toString(mappingSource)), MergeReason.MAPPING_UPDATE, false);
+ mapperService.merge("some_type", new CompressedXContent(Strings.toString(mappingSource)),
+ MergeReason.MAPPING_UPDATE, false);
Set allFields = new HashSet<>(mapperService.simpleMatchToFullName("*"));
assertTrue(allFields.contains("_parent"));
assertFalse(allFields.contains("_parent#null"));
diff --git a/server/src/test/java/org/elasticsearch/index/mapper/PathMapperTests.java b/server/src/test/java/org/elasticsearch/index/mapper/PathMapperTests.java
index 6bb15432b1fd3..c96b8c44ee707 100644
--- a/server/src/test/java/org/elasticsearch/index/mapper/PathMapperTests.java
+++ b/server/src/test/java/org/elasticsearch/index/mapper/PathMapperTests.java
@@ -31,7 +31,8 @@
public class PathMapperTests extends ESSingleNodeTestCase {
public void testPathMapping() throws IOException {
String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/path/test-mapping.json");
- DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser().parse("person", new CompressedXContent(mapping));
+ DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("person", new CompressedXContent(mapping));
// test full name
assertThat(docMapper.mappers().getMapper("first1"), nullValue());
diff --git a/server/src/test/java/org/elasticsearch/index/mapper/RoutingFieldMapperTests.java b/server/src/test/java/org/elasticsearch/index/mapper/RoutingFieldMapperTests.java
index 1b83b1bcb5b67..11c858545d03f 100644
--- a/server/src/test/java/org/elasticsearch/index/mapper/RoutingFieldMapperTests.java
+++ b/server/src/test/java/org/elasticsearch/index/mapper/RoutingFieldMapperTests.java
@@ -26,6 +26,7 @@
import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.test.ESSingleNodeTestCase;
+import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
public class RoutingFieldMapperTests extends ESSingleNodeTestCase {
@@ -33,7 +34,8 @@ public class RoutingFieldMapperTests extends ESSingleNodeTestCase {
public void testRoutingMapper() throws Exception {
String mapping = Strings.toString(XContentFactory.jsonBuilder().startObject().startObject("type")
.endObject().endObject());
- DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser().parse("type", new CompressedXContent(mapping));
+ DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("type", new CompressedXContent(mapping));
ParsedDocument doc = docMapper.parse(SourceToParse.source("test", "type", "1", BytesReference
.bytes(XContentFactory.jsonBuilder()
@@ -48,14 +50,16 @@ public void testRoutingMapper() throws Exception {
public void testIncludeInObjectNotAllowed() throws Exception {
String mapping = Strings.toString(XContentFactory.jsonBuilder().startObject().startObject("type").endObject().endObject());
- DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser().parse("type", new CompressedXContent(mapping));
+ DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("type", new CompressedXContent(mapping));
try {
docMapper.parse(SourceToParse.source("test", "type", "1", BytesReference.bytes(XContentFactory.jsonBuilder()
.startObject().field("_routing", "foo").endObject()),XContentType.JSON));
fail("Expected failure to parse metadata field");
} catch (MapperParsingException e) {
- assertTrue(e.getMessage(), e.getMessage().contains("Field [_routing] is a metadata field and cannot be added inside a document"));
+ assertThat(e.getMessage(), e.getMessage(),
+ containsString("Field [_routing] is a metadata field and cannot be added inside a document"));
}
}
}
diff --git a/server/src/test/java/org/elasticsearch/index/mapper/SourceFieldMapperTests.java b/server/src/test/java/org/elasticsearch/index/mapper/SourceFieldMapperTests.java
index 7266960508398..f364d1e37761f 100644
--- a/server/src/test/java/org/elasticsearch/index/mapper/SourceFieldMapperTests.java
+++ b/server/src/test/java/org/elasticsearch/index/mapper/SourceFieldMapperTests.java
@@ -46,7 +46,8 @@ public void testNoFormat() throws Exception {
DocumentMapperParser parser = createIndex("test").mapperService().documentMapperParser();
DocumentMapper documentMapper = parser.parse("type", new CompressedXContent(mapping));
- ParsedDocument doc = documentMapper.parse(SourceToParse.source("test", "type", "1", BytesReference.bytes(XContentFactory.jsonBuilder().startObject()
+ ParsedDocument doc = documentMapper.parse(SourceToParse.source("test", "type", "1",
+ BytesReference.bytes(XContentFactory.jsonBuilder().startObject()
.field("field", "value")
.endObject()),
XContentType.JSON));
@@ -54,7 +55,8 @@ public void testNoFormat() throws Exception {
assertThat(XContentFactory.xContentType(doc.source().toBytesRef().bytes), equalTo(XContentType.JSON));
documentMapper = parser.parse("type", new CompressedXContent(mapping));
- doc = documentMapper.parse(SourceToParse.source("test", "type", "1", BytesReference.bytes(XContentFactory.smileBuilder().startObject()
+ doc = documentMapper.parse(SourceToParse.source("test", "type", "1",
+ BytesReference.bytes(XContentFactory.smileBuilder().startObject()
.field("field", "value")
.endObject()),
XContentType.SMILE));
@@ -67,9 +69,11 @@ public void testIncludes() throws Exception {
.startObject("_source").array("includes", new String[]{"path1*"}).endObject()
.endObject().endObject());
- DocumentMapper documentMapper = createIndex("test").mapperService().documentMapperParser().parse("type", new CompressedXContent(mapping));
+ DocumentMapper documentMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("type", new CompressedXContent(mapping));
- ParsedDocument doc = documentMapper.parse(SourceToParse.source("test", "type", "1", BytesReference.bytes(XContentFactory.jsonBuilder().startObject()
+ ParsedDocument doc = documentMapper.parse(SourceToParse.source("test", "type", "1",
+ BytesReference.bytes(XContentFactory.jsonBuilder().startObject()
.startObject("path1").field("field1", "value1").endObject()
.startObject("path2").field("field2", "value2").endObject()
.endObject()),
@@ -89,9 +93,11 @@ public void testExcludes() throws Exception {
.startObject("_source").array("excludes", new String[]{"path1*"}).endObject()
.endObject().endObject());
- DocumentMapper documentMapper = createIndex("test").mapperService().documentMapperParser().parse("type", new CompressedXContent(mapping));
+ DocumentMapper documentMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("type", new CompressedXContent(mapping));
- ParsedDocument doc = documentMapper.parse(SourceToParse.source("test", "type", "1", BytesReference.bytes(XContentFactory.jsonBuilder().startObject()
+ ParsedDocument doc = documentMapper.parse(SourceToParse.source("test", "type", "1",
+ BytesReference.bytes(XContentFactory.jsonBuilder().startObject()
.startObject("path1").field("field1", "value1").endObject()
.startObject("path2").field("field2", "value2").endObject()
.endObject()),
@@ -241,10 +247,12 @@ public void testComplete() throws Exception {
public void testSourceObjectContainsExtraTokens() throws Exception {
String mapping = Strings.toString(XContentFactory.jsonBuilder().startObject().startObject("type").endObject().endObject());
- DocumentMapper documentMapper = createIndex("test").mapperService().documentMapperParser().parse("type", new CompressedXContent(mapping));
+ DocumentMapper documentMapper = createIndex("test").mapperService().documentMapperParser()
+ .parse("type", new CompressedXContent(mapping));
try {
- documentMapper.parse(SourceToParse.source("test", "type", "1", new BytesArray("{}}"), XContentType.JSON)); // extra end object (invalid JSON)
+ documentMapper.parse(SourceToParse.source("test", "type", "1",
+ new BytesArray("{}}"), XContentType.JSON)); // extra end object (invalid JSON)
fail("Expected parse exception");
} catch (MapperParsingException e) {
assertNotNull(e.getRootCause());
diff --git a/server/src/test/java/org/elasticsearch/index/mapper/UpdateMappingOnClusterIT.java b/server/src/test/java/org/elasticsearch/index/mapper/UpdateMappingOnClusterIT.java
index 338e5e4d5708d..15fe675d34ea2 100644
--- a/server/src/test/java/org/elasticsearch/index/mapper/UpdateMappingOnClusterIT.java
+++ b/server/src/test/java/org/elasticsearch/index/mapper/UpdateMappingOnClusterIT.java
@@ -42,7 +42,7 @@ protected boolean forbidPrivateIndexSettings() {
return false;
}
- protected void testConflict(String mapping, String mappingUpdate, Version idxVersion, String... errorMessages) throws InterruptedException {
+ protected void testConflict(String mapping, String mappingUpdate, Version idxVersion,String... errorMessages) {
assertAcked(prepareCreate(INDEX).setSource(mapping, XContentType.JSON)
.setSettings(Settings.builder().put("index.version.created", idxVersion.id)));
ensureGreen(INDEX);
@@ -101,7 +101,8 @@ private void compareMappingOnNodes(GetMappingsResponse previousMapping) {
// make sure all nodes have same cluster state
for (Client client : cluster().getClients()) {
GetMappingsResponse currentMapping = client.admin().indices().prepareGetMappings(INDEX).addTypes(TYPE).setLocal(true).get();
- assertThat(previousMapping.getMappings().get(INDEX).get(TYPE).source(), equalTo(currentMapping.getMappings().get(INDEX).get(TYPE).source()));
+ assertThat(previousMapping.getMappings().get(INDEX).get(TYPE).source(),
+ equalTo(currentMapping.getMappings().get(INDEX).get(TYPE).source()));
}
}
}
diff --git a/server/src/test/java/org/elasticsearch/index/mapper/UpdateMappingTests.java b/server/src/test/java/org/elasticsearch/index/mapper/UpdateMappingTests.java
index cdaa7ad8ba3cd..b9eb2e0c1bce5 100644
--- a/server/src/test/java/org/elasticsearch/index/mapper/UpdateMappingTests.java
+++ b/server/src/test/java/org/elasticsearch/index/mapper/UpdateMappingTests.java
@@ -72,7 +72,8 @@ protected void testConflictWhileMergingAndMappingUnchanged(XContentBuilder mappi
CompressedXContent mappingBeforeUpdate = indexService.mapperService().documentMapper("type").mappingSource();
// simulate like in MetaDataMappingService#putMapping
try {
- indexService.mapperService().merge("type", new CompressedXContent(BytesReference.bytes(mappingUpdate)), MapperService.MergeReason.MAPPING_UPDATE, false);
+ indexService.mapperService().merge("type", new CompressedXContent(BytesReference.bytes(mappingUpdate)),
+ MapperService.MergeReason.MAPPING_UPDATE, false);
fail();
} catch (IllegalArgumentException e) {
// expected