@Override public void merge(Mapper mergeWith, MergeContext mergeContext) throws MergeMappingException { AbstractFieldMapper fieldMergeWith = (AbstractFieldMapper) mergeWith; // do nothing here, no merging, but also no exception if (!mergeContext.mergeFlags().simulate()) { // apply changeable values if (fieldMergeWith.postingsFormatProvider() != null) { this.postingsFormat = fieldMergeWith.postingsFormatProvider(); } } }
@Override public void preParse(ParseContext context) throws IOException { if (context.sourceToParse().id() != null) { context.id(context.sourceToParse().id()); super.parse(context); } }
@Override public void postParse(ParseContext context) throws IOException { if (context.id() == null && !context.sourceToParse().flyweight()) { throw new MapperParsingException("No id found while parsing the content source"); } // if we did not have the id as part of the sourceToParse, then we need to parse it here // it would have been filled in the _id parse phase if (context.sourceToParse().id() == null) { super.parse(context); // since we did not have the uid in the pre phase, we did not add it automatically to the // nested docs // as they were created we need to make sure we add it to all the nested docs... if (context.docs().size() > 1) { UidField uidField = (UidField) context.rootDoc().getField(UidFieldMapper.NAME); assert uidField != null; // we need to go over the docs and add it... for (int i = 1; i < context.docs().size(); i++) { // we don't need to add it as a full uid field in nested docs, since we don't need // versioning context .docs() .get(i) .add(new Field(UidFieldMapper.NAME, uidField.uid(), Defaults.NESTED_FIELD_TYPE)); } } } }
@Override public void preParse(ParseContext context) throws IOException { // if we have the id provided, fill it, and parse now if (context.sourceToParse().id() != null) { context.id(context.sourceToParse().id()); super.parse(context); } }
@Override public void merge(Mapper mergeWith, MergeContext mergeContext) throws MergeMappingException { super.merge(mergeWith, mergeContext); if (!this.getClass().equals(mergeWith.getClass())) { return; } OntologySettings mergeSettings = ((OntologyMapper) mergeWith).ontologySettings; if (mergeSettings.getOntologyUri() != null && !mergeSettings.getOntologyUri().equals(ontologySettings.getOntologyUri())) { mergeContext.addConflict("mapper [" + names.fullName() + "] has different ontology URI"); } else if (mergeSettings.getOlsBaseUrl() != null && !mergeSettings.getOlsBaseUrl().equals(ontologySettings.getOlsBaseUrl())) { mergeContext.addConflict("mapper [" + names.fullName() + "] has different OLS base URL"); } }
@Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { if (pre13Index) { return builder; } boolean includeDefaults = params.paramAsBoolean("include_defaults", false); if (includeDefaults == false && fieldType().isEnabled() == Defaults.ENABLED) { return builder; } builder.startObject(NAME); if (includeDefaults || fieldType().isEnabled() != Defaults.ENABLED) { builder.field("enabled", fieldType().isEnabled()); } if (indexCreatedBefore2x && (includeDefaults || fieldType().equals(Defaults.FIELD_TYPE) == false)) { super.doXContentBody(builder, includeDefaults, params); } builder.endObject(); return builder; }
@Override public void preParse(ParseContext context) throws IOException { super.parse(context); }
@Override public void preParse(ParseContext context) throws IOException { // we pre parse it and not in parse, since its not part of the root object super.parse(context); }