Mapping: Dynamic mapping definitions are ignored, closes #274.
This commit is contained in:
parent
457b56937e
commit
1884c4219a
|
@ -19,6 +19,8 @@
|
|||
|
||||
package org.elasticsearch.index.mapper;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
|
@ -28,7 +30,7 @@ public interface DocumentMapperParser {
|
|||
* Parses the source mapping definition into a document mapper with the specified
|
||||
* type (overriding the one defined in the source mapping).
|
||||
*/
|
||||
DocumentMapper parse(String type, String mappingSource) throws MapperParsingException;
|
||||
DocumentMapper parse(@Nullable String type, String mappingSource) throws MapperParsingException;
|
||||
|
||||
/**
|
||||
* Parses the source mapping definition into a document mapper.
|
||||
|
|
|
@ -29,6 +29,7 @@ import org.elasticsearch.index.mapper.DocumentMapper;
|
|||
import org.elasticsearch.index.mapper.DocumentMapperParser;
|
||||
import org.elasticsearch.index.mapper.MapperParsingException;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -79,7 +80,7 @@ public class XContentDocumentMapperParser implements DocumentMapperParser {
|
|||
return parse(null, source);
|
||||
}
|
||||
|
||||
@Override public DocumentMapper parse(String type, String source) throws MapperParsingException {
|
||||
@Override public DocumentMapper parse(@Nullable String type, String source) throws MapperParsingException {
|
||||
Map<String, Object> root;
|
||||
XContentParser xContentParser = null;
|
||||
try {
|
||||
|
@ -107,6 +108,12 @@ public class XContentDocumentMapperParser implements DocumentMapperParser {
|
|||
throw new MapperParsingException("Expected root node name [" + rootName + "] to be of object type, but its not");
|
||||
}
|
||||
rootObj = (Map<String, Object>) tmpNode;
|
||||
} else if (rootName.equals("_default_")) {
|
||||
Object tmpNode = root.get("_default_");
|
||||
if (!(tmpNode instanceof Map)) {
|
||||
throw new MapperParsingException("_default_ mappings must have an inner object representing the actual mappings for the type");
|
||||
}
|
||||
rootObj = (Map<String, Object>) tmpNode;
|
||||
} else {
|
||||
rootObj = root;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue