@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 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); }