private Mapper parse(DocumentMapper mapper, DocumentMapperParser parser, XContentBuilder builder)
     throws Exception {
   Settings settings =
       Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT).build();
   ParseContext.InternalParseContext ctx =
       new ParseContext.InternalParseContext(settings, parser, mapper, new ContentPath(0));
   SourceToParse source = SourceToParse.source(builder.bytes());
   ctx.reset(XContentHelper.createParser(source.source()), new ParseContext.Document(), source);
   assertEquals(XContentParser.Token.START_OBJECT, ctx.parser().nextToken());
   ctx.parser().nextToken();
   DocumentParser.parseObjectOrNested(ctx, mapper.root(), true);
   Mapping mapping =
       DocumentParser.createDynamicUpdate(mapper.mapping(), mapper, ctx.getDynamicMappers());
   return mapping == null ? null : mapping.root();
 }
Exemplo n.º 2
0
 public void close() {
   documentParser.close();
 }
Exemplo n.º 3
0
 /**
  * Transform the source when it is expressed as a map. This is public so it can be transformed the
  * source is loaded.
  *
  * @param sourceAsMap source to transform. This may be mutated by the script.
  * @return transformed version of transformMe. This may actually be the same object as sourceAsMap
  */
 public Map<String, Object> transformSourceAsMap(Map<String, Object> sourceAsMap) {
   return DocumentParser.transformSourceAsMap(mapping, sourceAsMap);
 }
Exemplo n.º 4
0
 public ParsedDocument parse(SourceToParse source) throws MapperParsingException {
   return documentParser.parseDocument(source);
 }