private static void parseSettingsField(XContentParser parser, String currentIndexName, Map<String, Settings> indexToSettings, Map<String, Settings> indexToDefaultSettings) throws IOException { if (parser.currentToken() == XContentParser.Token.START_OBJECT) { switch (parser.currentName()) { case "settings": indexToSettings.put(currentIndexName, Settings.fromXContent(parser)); break; case "defaults": indexToDefaultSettings.put(currentIndexName, Settings.fromXContent(parser)); break; default: parser.skipChildren(); } } else if (parser.currentToken() == XContentParser.Token.START_ARRAY) { parser.skipChildren(); } parser.nextToken(); }
public static SearchProfileShardResults fromXContent(XContentParser parser) throws IOException { XContentParser.Token token = parser.currentToken(); ensureExpectedToken(XContentParser.Token.START_OBJECT, token, parser::getTokenLocation); Map<String, ProfileShardResult> searchProfileResults = new HashMap<>(); while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) { if (token == XContentParser.Token.START_ARRAY) { if (SHARDS_FIELD.equals(parser.currentName())) { while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) { parseSearchProfileResultsEntry(parser, searchProfileResults); } } else { parser.skipChildren(); } } else if (token == XContentParser.Token.START_OBJECT) { parser.skipChildren(); } } return new SearchProfileShardResults(searchProfileResults); }
successful = parser.intValue(); } else { parser.skipChildren(); parser.skipChildren(); // skip potential inner arrays for forward compatibility parser.skipChildren(); // skip potential inner arrays for forward compatibility
id = parser.text(); } else { parser.skipChildren(); aggProfileShardResult = AggregationProfileShardResult.fromXContent(parser); } else { parser.skipChildren(); parser.skipChildren();
rewriteTime = parser.longValue(); } else { parser.skipChildren(); parser.skipChildren(); parser.skipChildren();
parser.skipChildren(); parser.skipChildren();
nodeId = parser.text(); } else { parser.skipChildren(); exception = ElasticsearchException.fromXContent(parser); } else { parser.skipChildren(); parser.skipChildren();
private static void internalParseDocument(Mapping mapping, MetadataFieldMapper[] metadataFieldsMappers, ParseContext.InternalParseContext context, XContentParser parser) throws IOException { final boolean emptyDoc = isEmptyDoc(mapping, parser); for (MetadataFieldMapper metadataMapper : metadataFieldsMappers) { metadataMapper.preParse(context); } if (mapping.root.isEnabled() == false) { // entire type is disabled parser.skipChildren(); } else if (emptyDoc == false) { parseObjectOrNested(context, mapping.root); } for (MetadataFieldMapper metadataMapper : metadataFieldsMappers) { metadataMapper.postParse(context); } }
reason = ElasticsearchException.fromXContent(parser); } else { parser.skipChildren(); // skip potential inner objects for forward compatibility parser.skipChildren(); // skip potential inner arrays for forward compatibility
parser.skipChildren(); parser.nextToken(); throw new ElasticsearchParseException("coordinates cannot be specified as objects");
parser.skipChildren(); } else { throw new ParsingException(parser.getTokenLocation(), "Failed to parse object: empty key");
break; default: parser.skipChildren(); parser.skipChildren();
time = parser.longValue(); } else { parser.skipChildren(); parser.skipChildren(); parser.skipChildren();
public static GetSettingsResponse fromXContent(XContentParser parser) throws IOException { HashMap<String, Settings> indexToSettings = new HashMap<>(); HashMap<String, Settings> indexToDefaultSettings = new HashMap<>(); if (parser.currentToken() == null) { parser.nextToken(); } XContentParserUtils.ensureExpectedToken(XContentParser.Token.START_OBJECT, parser.currentToken(), parser::getTokenLocation); parser.nextToken(); while (!parser.isClosed()) { if (parser.currentToken() == XContentParser.Token.START_OBJECT) { //we must assume this is an index entry parseIndexEntry(parser, indexToSettings, indexToDefaultSettings); } else if (parser.currentToken() == XContentParser.Token.START_ARRAY) { parser.skipChildren(); } else { parser.nextToken(); } } ImmutableOpenMap<String, Settings> settingsMap = ImmutableOpenMap.<String, Settings>builder().putAll(indexToSettings).build(); ImmutableOpenMap<String, Settings> defaultSettingsMap = ImmutableOpenMap.<String, Settings>builder().putAll(indexToDefaultSettings).build(); return new GetSettingsResponse(settingsMap, defaultSettingsMap); }
private static ImmutableOpenMap<String, MappingMetaData> parseMappings(XContentParser parser) throws IOException { ImmutableOpenMap.Builder<String, MappingMetaData> indexMappings = ImmutableOpenMap.builder(); // We start at START_OBJECT since parseIndexEntry ensures that while (parser.nextToken() != Token.END_OBJECT) { ensureExpectedToken(Token.FIELD_NAME, parser.currentToken(), parser::getTokenLocation); parser.nextToken(); if (parser.currentToken() == Token.START_OBJECT) { String mappingType = parser.currentName(); indexMappings.put(mappingType, new MappingMetaData(mappingType, parser.map())); } else if (parser.currentToken() == Token.START_ARRAY) { parser.skipChildren(); } } return indexMappings.build(); }
parser.skipChildren(); } else { parser.nextToken();
static void parseObjectOrNested(ParseContext context, ObjectMapper mapper) throws IOException { if (mapper.isEnabled() == false) { context.parser().skipChildren(); return;
} else { context.parser().skipChildren();