org.elasticsearch.index.mapper.object.ObjectMapper Java Examples
The following examples show how to use
org.elasticsearch.index.mapper.object.ObjectMapper.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ArrayMapper.java From Elasticsearch with Apache License 2.0 | 6 votes |
public Mapper create(String name, ObjectMapper parentMapper, ParseContext context) { BuilderContext builderContext = new BuilderContext(context.indexSettings(), context.path()); try { Mapper.Builder<?, ?> innerBuilder = detectInnerMapper(context, name, context.parser()); if (innerBuilder == null) { return null; } Mapper mapper = innerBuilder.build(builderContext); mapper = DocumentParser.parseAndMergeUpdate(mapper, context); MappedFieldType mappedFieldType = newArrayFieldType(innerBuilder); String fullName = context.path().fullPathAsText(name); mappedFieldType.setNames(new MappedFieldType.Names(fullName)); return new ArrayMapper( name, mappedFieldType, mappedFieldType.clone(), context.indexSettings(), MultiFields.empty(), null, mapper); } catch (IOException e) { throw Throwables.propagate(e); } }
Example #2
Source File: ArrayMapper.java From Elasticsearch with Apache License 2.0 | 6 votes |
@Override public Mapper.Builder parse(String name, Map<String, Object> node, ParserContext parserContext) throws MapperParsingException { Object inner = node.remove(INNER_TYPE); if (inner == null) { throw new MapperParsingException("property [inner] missing"); } if (!(inner instanceof Map)) { throw new MapperParsingException("property [inner] must be a map"); } @SuppressWarnings("unchecked") Map<String, Object> innerNode = (Map<String, Object>) inner; String typeName = (String)innerNode.get("type"); if (typeName == null && innerNode.containsKey("properties")) { typeName = ObjectMapper.CONTENT_TYPE; } else if (CONTENT_TYPE.equalsIgnoreCase(typeName)) { throw new MapperParsingException("nested arrays are not supported"); } Mapper.TypeParser innerTypeParser = parserContext.typeParser(typeName); Mapper.Builder innerBuilder = innerTypeParser.parse(name, innerNode, parserContext); return new Builder(name, innerBuilder); }
Example #3
Source File: ArrayMapper.java From Elasticsearch with Apache License 2.0 | 6 votes |
@Override protected void doMerge(Mapper mergeWith, boolean updateAllTypes) { if (mergeWith instanceof ArrayMapper) { innerMapper = innerMapper.merge(((ArrayMapper) mergeWith).innerMapper, updateAllTypes); } else { innerMapper = innerMapper.merge(mergeWith, updateAllTypes); } MappedFieldType newArrayFieldType = null; if (innerMapper instanceof ObjectMapper) { newArrayFieldType = new ObjectArrayFieldType(); } if (innerMapper instanceof FieldMapper) { newArrayFieldType = new ArrayFieldType(((FieldMapper) innerMapper).fieldType()); } newArrayFieldType.setNames(this.fieldType.names()); this.fieldType = newArrayFieldType; }
Example #4
Source File: IndicesModule.java From Elasticsearch with Apache License 2.0 | 6 votes |
private void registerBuiltInMappers() { registerMapper(ByteFieldMapper.CONTENT_TYPE, new ByteFieldMapper.TypeParser()); registerMapper(ShortFieldMapper.CONTENT_TYPE, new ShortFieldMapper.TypeParser()); registerMapper(IntegerFieldMapper.CONTENT_TYPE, new IntegerFieldMapper.TypeParser()); registerMapper(LongFieldMapper.CONTENT_TYPE, new LongFieldMapper.TypeParser()); registerMapper(FloatFieldMapper.CONTENT_TYPE, new FloatFieldMapper.TypeParser()); registerMapper(DoubleFieldMapper.CONTENT_TYPE, new DoubleFieldMapper.TypeParser()); registerMapper(BooleanFieldMapper.CONTENT_TYPE, new BooleanFieldMapper.TypeParser()); registerMapper(BinaryFieldMapper.CONTENT_TYPE, new BinaryFieldMapper.TypeParser()); registerMapper(DateFieldMapper.CONTENT_TYPE, new DateFieldMapper.TypeParser()); registerMapper(IpFieldMapper.CONTENT_TYPE, new IpFieldMapper.TypeParser()); registerMapper(StringFieldMapper.CONTENT_TYPE, new StringFieldMapper.TypeParser()); registerMapper(TokenCountFieldMapper.CONTENT_TYPE, new TokenCountFieldMapper.TypeParser()); registerMapper(ObjectMapper.CONTENT_TYPE, new ObjectMapper.TypeParser()); registerMapper(ObjectMapper.NESTED_CONTENT_TYPE, new ObjectMapper.TypeParser()); registerMapper(TypeParsers.MULTI_FIELD_CONTENT_TYPE, TypeParsers.multiFieldConverterTypeParser); registerMapper(CompletionFieldMapper.CONTENT_TYPE, new CompletionFieldMapper.TypeParser()); registerMapper(GeoPointFieldMapper.CONTENT_TYPE, new GeoPointFieldMapper.TypeParser()); if (ShapesAvailability.JTS_AVAILABLE) { registerMapper(GeoShapeFieldMapper.CONTENT_TYPE, new GeoShapeFieldMapper.TypeParser()); } }
Example #5
Source File: MapperTestUtils.java From elasticsearch-analysis-baseform with Apache License 2.0 | 6 votes |
private static Map<String, Mapper.TypeParser> registerBuiltInMappers() { Map<String, Mapper.TypeParser> mapperParsers = new LinkedHashMap<>(); mapperParsers.put(ByteFieldMapper.CONTENT_TYPE, new ByteFieldMapper.TypeParser()); mapperParsers.put(ShortFieldMapper.CONTENT_TYPE, new ShortFieldMapper.TypeParser()); mapperParsers.put(IntegerFieldMapper.CONTENT_TYPE, new IntegerFieldMapper.TypeParser()); mapperParsers.put(LongFieldMapper.CONTENT_TYPE, new LongFieldMapper.TypeParser()); mapperParsers.put(FloatFieldMapper.CONTENT_TYPE, new FloatFieldMapper.TypeParser()); mapperParsers.put(DoubleFieldMapper.CONTENT_TYPE, new DoubleFieldMapper.TypeParser()); mapperParsers.put(BooleanFieldMapper.CONTENT_TYPE, new BooleanFieldMapper.TypeParser()); mapperParsers.put(BinaryFieldMapper.CONTENT_TYPE, new BinaryFieldMapper.TypeParser()); mapperParsers.put(DateFieldMapper.CONTENT_TYPE, new DateFieldMapper.TypeParser()); mapperParsers.put(IpFieldMapper.CONTENT_TYPE, new IpFieldMapper.TypeParser()); mapperParsers.put(StringFieldMapper.CONTENT_TYPE, new StringFieldMapper.TypeParser()); mapperParsers.put(TokenCountFieldMapper.CONTENT_TYPE, new TokenCountFieldMapper.TypeParser()); mapperParsers.put(ObjectMapper.CONTENT_TYPE, new ObjectMapper.TypeParser()); mapperParsers.put(ObjectMapper.NESTED_CONTENT_TYPE, new ObjectMapper.TypeParser()); mapperParsers.put(TypeParsers.MULTI_FIELD_CONTENT_TYPE, TypeParsers.multiFieldConverterTypeParser); mapperParsers.put(CompletionFieldMapper.CONTENT_TYPE, new CompletionFieldMapper.TypeParser()); mapperParsers.put(GeoPointFieldMapper.CONTENT_TYPE, new GeoPointFieldMapper.TypeParser()); return mapperParsers; }
Example #6
Source File: LocalWeatherDataMapper.java From JavaElasticSearchExperiment with MIT License | 6 votes |
@Override protected void configure(RootObjectMapper.Builder builder) { builder .add(new DateFieldMapper.Builder("dateTime")) .add(new FloatFieldMapper.Builder("temperature")) .add(new FloatFieldMapper.Builder("windSpeed")) .add(new FloatFieldMapper.Builder("stationPressure")) .add(new StringFieldMapper.Builder("skyCondition")) .add(new ObjectMapper.Builder("station") .add(new StringFieldMapper.Builder("wban")) .add(new StringFieldMapper.Builder("name")) .add(new StringFieldMapper.Builder("state")) .add(new StringFieldMapper.Builder("location")) .add(new GeoPointFieldMapper.Builder("coordinates") .enableLatLon(true) .enableGeoHash(false)) .nested(ObjectMapper.Nested.newNested(true, false))); }
Example #7
Source File: ReverseNestedAggregator.java From Elasticsearch with Apache License 2.0 | 6 votes |
@Override public Aggregator createInternal(AggregationContext context, Aggregator parent, boolean collectsFromSingleBucket, List<PipelineAggregator> pipelineAggregators, Map<String, Object> metaData) throws IOException { // Early validation NestedAggregator closestNestedAggregator = findClosestNestedAggregator(parent); if (closestNestedAggregator == null) { throw new SearchParseException(context.searchContext(), "Reverse nested aggregation [" + name + "] can only be used inside a [nested] aggregation", null); } final ObjectMapper objectMapper; if (path != null) { objectMapper = context.searchContext().getObjectMapper(path); if (objectMapper == null) { return new Unmapped(name, context, parent, pipelineAggregators, metaData); } if (!objectMapper.nested().isNested()) { throw new AggregationExecutionException("[reverse_nested] nested path [" + path + "] is not nested"); } } else { objectMapper = null; } return new ReverseNestedAggregator(name, factories, objectMapper, context, parent, pipelineAggregators, metaData); }
Example #8
Source File: LocalWeatherDataMapper.java From ElasticUtils with MIT License | 6 votes |
@Override protected void configureRootObjectBuilder(RootObjectMapper.Builder builder) { builder .add(new DateFieldMapper.Builder("dateTime")) .add(new FloatFieldMapper.Builder("temperature")) .add(new FloatFieldMapper.Builder("windSpeed")) .add(new FloatFieldMapper.Builder("stationPressure")) .add(new StringFieldMapper.Builder("skyCondition")) .add(new ObjectMapper.Builder("station") .add(new StringFieldMapper.Builder("wban")) .add(new StringFieldMapper.Builder("name")) .add(new StringFieldMapper.Builder("state")) .add(new StringFieldMapper.Builder("location")) .add(new GeoPointFieldMapper.Builder("coordinates") .enableLatLon(true) .enableGeoHash(false)) .nested(ObjectMapper.Nested.newNested(true, false))); }
Example #9
Source File: MapperService.java From Elasticsearch with Apache License 2.0 | 6 votes |
/** * Resolves the closest inherited {@link ObjectMapper} that is nested. */ public ObjectMapper resolveClosestNestedObjectMapper(String fieldName) { int indexOf = fieldName.lastIndexOf('.'); if (indexOf == -1) { return null; } else { do { String objectPath = fieldName.substring(0, indexOf); ObjectMapper objectMapper = fullPathObjectMappers.get(objectPath); if (objectMapper == null) { indexOf = objectPath.lastIndexOf('.'); continue; } if (objectMapper.nested().isNested()) { return objectMapper; } indexOf = objectPath.lastIndexOf('.'); } while (indexOf != -1); } return null; }
Example #10
Source File: DocumentParser.java From Elasticsearch with Apache License 2.0 | 6 votes |
private static ObjectMapper 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) { if (token == XContentParser.Token.START_OBJECT) { return parseObject(context, mapper, lastFieldName); } else if (token == XContentParser.Token.START_ARRAY) { return parseArray(context, mapper, lastFieldName); } else if (token == XContentParser.Token.FIELD_NAME) { lastFieldName = parser.currentName(); } 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?"); } else { return parseValue(context, mapper, lastFieldName, token); } } return null; }
Example #11
Source File: NestedInnerQueryParseSupport.java From Elasticsearch with Apache License 2.0 | 5 votes |
private void setPathLevel() { ObjectMapper objectMapper = parseContext.nestedScope().getObjectMapper(); if (objectMapper == null) { parentFilter = parseContext.bitsetFilter(Queries.newNonNestedFilter()); } else { parentFilter = parseContext.bitsetFilter(objectMapper.nestedTypeFilter()); } childFilter = nestedObjectMapper.nestedTypeFilter(); parentObjectMapper = parseContext.nestedScope().nextLevel(nestedObjectMapper); }
Example #12
Source File: ArrayMapper.java From Elasticsearch with Apache License 2.0 | 5 votes |
private static MappedFieldType newArrayFieldType(Mapper.Builder innerBuilder) { if (innerBuilder instanceof FieldMapper.Builder) { return new ArrayFieldType(((FieldMapper.Builder) innerBuilder).fieldType()); } if (innerBuilder instanceof ObjectMapper.Builder) { return new ObjectArrayFieldType(); } throw new IllegalArgumentException("expected a FieldMapper.Builder or ObjectMapper.Builder"); }
Example #13
Source File: MapperService.java From Elasticsearch with Apache License 2.0 | 5 votes |
private void checkObjectsCompatibility(String type, Collection<ObjectMapper> objectMappers, Collection<FieldMapper> fieldMappers, boolean updateAllTypes) { assert Thread.holdsLock(this); for (ObjectMapper newObjectMapper : objectMappers) { ObjectMapper existingObjectMapper = fullPathObjectMappers.get(newObjectMapper.fullPath()); if (existingObjectMapper != null) { // simulate a merge and ignore the result, we are just interested // in exceptions here existingObjectMapper.merge(newObjectMapper, updateAllTypes); } } }
Example #14
Source File: MapperService.java From Elasticsearch with Apache License 2.0 | 5 votes |
private void checkNestedFieldsLimit(Map<String, ObjectMapper> fullPathObjectMappers) { long allowedNestedFields = indexSettingsService.getSettings().getAsLong(INDEX_MAPPING_NESTED_FIELDS_LIMIT_SETTING, 50L); long actualNestedFields = 0; for (ObjectMapper objectMapper : fullPathObjectMappers.values()) { if (objectMapper.nested().isNested()) { actualNestedFields++; } } if (allowedNestedFields >= 0 && actualNestedFields > allowedNestedFields) { throw new IllegalArgumentException("Limit of nested fields [" + allowedNestedFields + "] in index [" + index().name() + "] has been exceeded"); } }
Example #15
Source File: DocumentMapper.java From Elasticsearch with Apache License 2.0 | 5 votes |
/** * Returns the best nested {@link ObjectMapper} instances that is in the scope of the specified nested docId. */ public ObjectMapper findNestedObjectMapper(int nestedDocId, SearchContext sc, LeafReaderContext context) throws IOException { ObjectMapper nestedObjectMapper = null; for (ObjectMapper objectMapper : objectMappers().values()) { if (!objectMapper.nested().isNested()) { continue; } Query filter = objectMapper.nestedTypeFilter(); if (filter == null) { continue; } // We can pass down 'null' as acceptedDocs, because nestedDocId is a doc to be fetched and // therefor is guaranteed to be a live doc. final Weight nestedWeight = filter.createWeight(sc.searcher(), false); Scorer scorer = nestedWeight.scorer(context); if (scorer == null) { continue; } if (scorer.iterator().advance(nestedDocId) == nestedDocId) { if (nestedObjectMapper == null) { nestedObjectMapper = objectMapper; } else { if (nestedObjectMapper.fullPath().length() < objectMapper.fullPath().length()) { nestedObjectMapper = objectMapper; } } } } return nestedObjectMapper; }
Example #16
Source File: DocumentMapper.java From Elasticsearch with Apache License 2.0 | 5 votes |
/** * Returns the parent {@link ObjectMapper} instance of the specified object mapper or <code>null</code> if there * isn't any. */ // TODO: We should add: ObjectMapper#getParentObjectMapper() public ObjectMapper findParentObjectMapper(ObjectMapper objectMapper) { int indexOfLastDot = objectMapper.fullPath().lastIndexOf('.'); if (indexOfLastDot != -1) { String parentNestObjectPath = objectMapper.fullPath().substring(0, indexOfLastDot); return objectMappers().get(parentNestObjectPath); } else { return null; } }
Example #17
Source File: DocumentParser.java From Elasticsearch with Apache License 2.0 | 5 votes |
static Mapper parseObjectOrField(ParseContext context, Mapper mapper) throws IOException { if (mapper instanceof ObjectMapper) { return parseObject(context, (ObjectMapper) mapper, false); } else { FieldMapper fieldMapper = (FieldMapper)mapper; Mapper update = fieldMapper.parse(context); if (fieldMapper.copyTo() != null) { parseCopyFields(context, fieldMapper, fieldMapper.copyTo().copyToFields()); } return update; } }
Example #18
Source File: DocumentParser.java From Elasticsearch with Apache License 2.0 | 5 votes |
static ObjectMapper 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() + "]"); } Mapper mapper = parentMapper.getMapper(currentFieldName); if (mapper != null) { Mapper subUpdate = parseObjectOrField(context, mapper); if (subUpdate == null) { return null; } return parentMapper.mappingUpdate(subUpdate); } else { return parseDynamicValue(context, parentMapper, currentFieldName, token); } }
Example #19
Source File: DocumentParser.java From Elasticsearch with Apache License 2.0 | 5 votes |
private static void parseNullValue(ParseContext context, ObjectMapper parentMapper, String lastFieldName) throws IOException { // we can only handle null values if we have mappings for them Mapper mapper = parentMapper.getMapper(lastFieldName); if (mapper != null) { // TODO: passing null to an object seems bogus? parseObjectOrField(context, mapper); } else if (parentMapper.dynamic() == ObjectMapper.Dynamic.STRICT) { throw new StrictDynamicMappingException(parentMapper.fullPath(), lastFieldName); } }
Example #20
Source File: DocumentParser.java From Elasticsearch with Apache License 2.0 | 5 votes |
private static ObjectMapper parseDynamicValue(final ParseContext context, ObjectMapper parentMapper, String currentFieldName, XContentParser.Token token) throws IOException { Mapper mapper = mapperFromDynamicValue(context, parentMapper, currentFieldName, token); ObjectMapper update = null; if (mapper != null) { update = parentMapper.mappingUpdate(mapper); } return update; }
Example #21
Source File: DocumentParser.java From Elasticsearch with Apache License 2.0 | 5 votes |
static Mapper mapperFromDynamicValue(final ParseContext context, ObjectMapper parentMapper, String currentFieldName, XContentParser.Token token) throws IOException { ObjectMapper.Dynamic dynamic = parentMapper.dynamic(); if (dynamic == null) { dynamic = dynamicOrDefault(context.root().dynamic()); } if (dynamic == ObjectMapper.Dynamic.STRICT) { throw new StrictDynamicMappingException(parentMapper.fullPath(), currentFieldName); } if (dynamic == ObjectMapper.Dynamic.FALSE) { return null; } final String path = context.path().fullPathAsText(currentFieldName); final Mapper.BuilderContext builderContext = new Mapper.BuilderContext(context.indexSettings(), context.path()); final MappedFieldType existingFieldType = context.mapperService().fullName(path); Mapper.Builder builder = null; if (existingFieldType != null) { // create a builder of the same type builder = createBuilderFromFieldType(context, existingFieldType, currentFieldName); } if (builder == null) { builder = createBuilderFromDynamicValue(context, token, currentFieldName); } Mapper mapper = builder.build(builderContext); if (existingFieldType != null) { // try to not introduce a conflict mapper = mapper.updateFieldType(Collections.singletonMap(path, existingFieldType)); } return parseAndMergeUpdate(mapper, context); }
Example #22
Source File: ReverseNestedAggregator.java From Elasticsearch with Apache License 2.0 | 5 votes |
public ReverseNestedAggregator(String name, AggregatorFactories factories, ObjectMapper objectMapper, AggregationContext aggregationContext, Aggregator parent, List<PipelineAggregator> pipelineAggregators, Map<String, Object> metaData) throws IOException { super(name, factories, aggregationContext, parent, pipelineAggregators, metaData); if (objectMapper == null) { parentFilter = Queries.newNonNestedFilter(); } else { parentFilter = objectMapper.nestedTypeFilter(); } parentBitsetProducer = context.searchContext().bitsetFilterCache().getBitSetProducer(parentFilter); }
Example #23
Source File: NestedAggregator.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override public Aggregator createInternal(AggregationContext context, Aggregator parent, boolean collectsFromSingleBucket, List<PipelineAggregator> pipelineAggregators, Map<String, Object> metaData) throws IOException { if (collectsFromSingleBucket == false) { return asMultiBucketAggregator(this, context, parent); } ObjectMapper objectMapper = context.searchContext().getObjectMapper(path); if (objectMapper == null) { return new Unmapped(name, context, parent, pipelineAggregators, metaData); } if (!objectMapper.nested().isNested()) { throw new AggregationExecutionException("[nested] nested path [" + path + "] is not nested"); } return new NestedAggregator(name, factories, objectMapper, context, parent, pipelineAggregators, metaData); }
Example #24
Source File: InnerHitsParseElement.java From Elasticsearch with Apache License 2.0 | 5 votes |
private InnerHitsContext.NestedInnerHits parseNested(XContentParser parser, QueryParseContext parseContext, SearchContext searchContext, String nestedPath) throws Exception { ObjectMapper objectMapper = searchContext.getObjectMapper(nestedPath); if (objectMapper == null) { throw new IllegalArgumentException("path [" + nestedPath +"] doesn't exist"); } if (objectMapper.nested().isNested() == false) { throw new IllegalArgumentException("path [" + nestedPath +"] isn't nested"); } ObjectMapper parentObjectMapper = parseContext.nestedScope().nextLevel(objectMapper); ParseResult parseResult = parseSubSearchContext(searchContext, parseContext, parser); parseContext.nestedScope().previousLevel(); return new InnerHitsContext.NestedInnerHits(parseResult.context(), parseResult.query(), parseResult.childInnerHits(), parentObjectMapper, objectMapper); }
Example #25
Source File: DefaultSearchContext.java From Elasticsearch with Apache License 2.0 | 4 votes |
@Override public ObjectMapper getObjectMapper(String name) { return mapperService().getObjectMapper(name, request.types()); }
Example #26
Source File: PercolateContext.java From Elasticsearch with Apache License 2.0 | 4 votes |
@Override public ObjectMapper getObjectMapper(String name) { throw new UnsupportedOperationException(); }
Example #27
Source File: NestedAggregator.java From Elasticsearch with Apache License 2.0 | 4 votes |
public NestedAggregator(String name, AggregatorFactories factories, ObjectMapper objectMapper, AggregationContext aggregationContext, Aggregator parentAggregator, List<PipelineAggregator> pipelineAggregators, Map<String, Object> metaData) throws IOException { super(name, factories, aggregationContext, parentAggregator, pipelineAggregators, metaData); childFilter = objectMapper.nestedTypeFilter(); }
Example #28
Source File: TypeParsers.java From Elasticsearch with Apache License 2.0 | 4 votes |
public static boolean parseMultiField(FieldMapper.Builder builder, String name, Mapper.TypeParser.ParserContext parserContext, String propName, Object propNode) { parserContext = parserContext.createMultiFieldContext(parserContext); if (propName.equals("path") && parserContext.indexVersionCreated().before(Version.V_2_0_0_beta1)) { builder.multiFieldPathType(parsePathType(name, propNode.toString())); return true; } else if (propName.equals("fields")) { final Map<String, Object> multiFieldsPropNodes; if (propNode instanceof List && ((List<?>) propNode).isEmpty()) { multiFieldsPropNodes = Collections.emptyMap(); } else if (propNode instanceof Map) { multiFieldsPropNodes = (Map<String, Object>) propNode; } else { throw new MapperParsingException("expected map for property [fields] on field [" + propNode + "] or " + "[" + propName + "] but got a " + propNode.getClass()); } for (Map.Entry<String, Object> multiFieldEntry : multiFieldsPropNodes.entrySet()) { String multiFieldName = multiFieldEntry.getKey(); if (multiFieldName.contains(".")) { throw new MapperParsingException("Field name [" + multiFieldName + "] which is a multi field of [" + name + "] cannot contain '.'"); } if (!(multiFieldEntry.getValue() instanceof Map)) { throw new MapperParsingException("illegal field [" + multiFieldName + "], only fields can be specified inside fields"); } @SuppressWarnings("unchecked") Map<String, Object> multiFieldNodes = (Map<String, Object>) multiFieldEntry.getValue(); String type; Object typeNode = multiFieldNodes.get("type"); if (typeNode != null) { type = typeNode.toString(); } else { throw new MapperParsingException("no type specified for property [" + multiFieldName + "]"); } if (type.equals(ObjectMapper.CONTENT_TYPE) || type.equals(ObjectMapper.NESTED_CONTENT_TYPE)) { throw new MapperParsingException("Type [" + type + "] cannot be used in multi field"); } Mapper.TypeParser typeParser = parserContext.typeParser(type); if (typeParser == null) { throw new MapperParsingException("no handler for type [" + type + "] declared on field [" + multiFieldName + "]"); } builder.addMultiField(typeParser.parse(multiFieldName, multiFieldNodes, parserContext)); multiFieldNodes.remove("type"); DocumentMapperParser.checkNoRemainingFields(propName, multiFieldNodes, parserContext.indexVersionCreated()); } return true; } return false; }
Example #29
Source File: MapperBuilders.java From Elasticsearch with Apache License 2.0 | 4 votes |
public static ObjectMapper.Builder object(String name) { return new ObjectMapper.Builder(name); }
Example #30
Source File: DocumentParser.java From Elasticsearch with Apache License 2.0 | 4 votes |
private static ObjectMapper.Dynamic dynamicOrDefault(ObjectMapper.Dynamic dynamic) { return dynamic == null ? ObjectMapper.Dynamic.TRUE : dynamic; }