Skip to content

Commit

Permalink
Merge pull request #19937 from rjernst/dots_in_mappers
Browse files Browse the repository at this point in the history
Mappings: Allow to force dots in field names
  • Loading branch information
rjernst committed Aug 11, 2016
2 parents 241be19 + 266bd52 commit 69db1c1
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.apache.lucene.util.BytesRef;
import org.elasticsearch.ElasticsearchParseException;
import org.elasticsearch.Version;
import org.elasticsearch.common.Booleans;
import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.collect.CopyOnWriteHashMap;
Expand Down Expand Up @@ -61,6 +62,9 @@ public class ObjectMapper extends Mapper implements AllFieldMapper.IncludeInAll,
public static final String CONTENT_TYPE = "object";
public static final String NESTED_CONTENT_TYPE = "nested";

private static final boolean DOTS_IN_FIELD_ALLOWED = Booleans.parseBooleanExact(
System.getProperty("mapper.allow_dots_in_name", "false"));

public static class Defaults {
public static final boolean ENABLED = true;
public static final Nested NESTED = Nested.NO;
Expand Down Expand Up @@ -269,7 +273,7 @@ protected static void parseProperties(ObjectMapper.Builder objBuilder, Map<Strin
while (iterator.hasNext()) {
Map.Entry<String, Object> entry = iterator.next();
String fieldName = entry.getKey();
if (fieldName.contains(".")) {
if (fieldName.contains(".") && DOTS_IN_FIELD_ALLOWED == false) {
throw new MapperParsingException("Field name [" + fieldName + "] cannot contain '.'");
}
// Should accept empty arrays, as a work around for when the
Expand Down

0 comments on commit 69db1c1

Please sign in to comment.