Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Mappings: Allow to force dots in field names #19937

Merged
merged 1 commit into from
Aug 11, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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