Mapping: Allow to specify enabled set to false on a property without specifying the type, closes #1959.

This commit is contained in:
Shay Banon 2012-05-16 22:33:44 +03:00
parent 11a1f69257
commit 07e0888b3e
1 changed files with 5 additions and 0 deletions

View File

@ -244,6 +244,11 @@ public class ObjectMapper implements Mapper, AllFieldMapper.IncludeInAll {
type = ObjectMapper.CONTENT_TYPE;
} else if (propNode.get("fields") != null) {
type = MultiFieldMapper.CONTENT_TYPE;
} else if (propNode.size() == 1 && propNode.get("enabled") != null) {
// if there is a single property with the enabled flag on it, make it an object
// (usually, setting enabled to false to not index any type, including core values, which
// non enabled object type supports).
type = ObjectMapper.CONTENT_TYPE;
} else {
throw new MapperParsingException("No type specified for property [" + propName + "]");
}