public Builder putMapping(String mappingType, String mappingSource) throws IOException { mappings.put(mappingType, new CompressedXContent(mappingSource)); return this; }
public void merge(Map<String, Map<String, Object>> mappings, MergeReason reason, boolean updateAllTypes) { Map<String, CompressedXContent> mappingSourcesCompressed = new LinkedHashMap<>(mappings.size()); for (Map.Entry<String, Map<String, Object>> entry : mappings.entrySet()) { try { mappingSourcesCompressed.put(entry.getKey(), new CompressedXContent(Strings.toString( XContentFactory.jsonBuilder().map(entry.getValue())))); } catch (Exception e) { throw new MapperParsingException("Failed to parse mapping [{}]: {}", e, entry.getKey(), e.getMessage()); } } internalMerge(mappingSourcesCompressed, reason, updateAllTypes); }
public MappingMetaData(String type, Map<String, Object> mapping) throws IOException { this.type = type; XContentBuilder mappingBuilder = XContentFactory.jsonBuilder().map(mapping); this.source = new CompressedXContent(BytesReference.bytes(mappingBuilder)); Map<String, Object> withoutType = mapping; if (mapping.size() == 1 && mapping.containsKey(type)) { withoutType = (Map<String, Object>) mapping.get(type); } initMappers(withoutType); }
public static CompressedXContent readCompressedString(StreamInput in) throws IOException { int crc32 = in.readInt(); byte[] compressed = new byte[in.readVInt()]; in.readBytes(compressed, 0, compressed.length); return new CompressedXContent(compressed, crc32); }
public Builder filter(Map<String, Object> filter) { if (filter == null || filter.isEmpty()) { this.filter = null; return this; } try { XContentBuilder builder = XContentFactory.jsonBuilder().map(filter); this.filter = new CompressedXContent(BytesReference.bytes(builder)); return this; } catch (IOException e) { throw new ElasticsearchGenerationException("Failed to build json for alias request", e); } }
mappingSource = new CompressedXContent(this, XContentType.JSON, ToXContent.EMPTY_PARAMS); } catch (Exception e) { throw new ElasticsearchGenerationException("failed to serialize source for type [" + type + "]", e);
builder.filter(new CompressedXContent(parser.binaryValue()));
while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) { if (token == XContentParser.Token.VALUE_EMBEDDED_OBJECT) { builder.putMapping(new MappingMetaData(new CompressedXContent(parser.binaryValue()))); } else { Map<String, Object> mapping = parser.mapOrdered();
private MappingMetaData() { this.type = ""; try { this.source = new CompressedXContent("{}"); } catch (IOException ex) { throw new IllegalStateException("Cannot create MappingMetaData prototype", ex); } }
private ClusterState applyRequest(ClusterState currentState, PutMappingClusterStateUpdateRequest request, Map<Index, MapperService> indexMapperServices) throws IOException { String mappingType = request.type(); CompressedXContent mappingUpdateSource = new CompressedXContent(request.source()); final MetaData metaData = currentState.metaData(); final List<IndexMetaData> updateList = new ArrayList<>();
public void merge(Map<String, Map<String, Object>> mappings, MergeReason reason, boolean updateAllTypes) { Map<String, CompressedXContent> mappingSourcesCompressed = new LinkedHashMap<>(mappings.size()); for (Map.Entry<String, Map<String, Object>> entry : mappings.entrySet()) { try { mappingSourcesCompressed.put(entry.getKey(), new CompressedXContent(XContentFactory.jsonBuilder().map(entry.getValue()).string())); } catch (Exception e) { throw new MapperParsingException("Failed to parse mapping [{}]: {}", e, entry.getKey(), e.getMessage()); } } internalMerge(mappingSourcesCompressed, reason, updateAllTypes); }
public void merge(Map<String, Map<String, Object>> mappings, MergeReason reason, boolean updateAllTypes) { Map<String, CompressedXContent> mappingSourcesCompressed = new LinkedHashMap<>(mappings.size()); for (Map.Entry<String, Map<String, Object>> entry : mappings.entrySet()) { try { mappingSourcesCompressed.put(entry.getKey(), new CompressedXContent(Strings.toString(XContentFactory.jsonBuilder().map(entry.getValue())))); } catch (Exception e) { throw new MapperParsingException("Failed to parse mapping [{}]: {}", e, entry.getKey(), e.getMessage()); } } internalMerge(mappingSourcesCompressed, reason, updateAllTypes); }
public void testEmptyName() throws IOException { // after version 5 for (String type : TYPES) { String mapping = XContentFactory.jsonBuilder().startObject().startObject("type") .startObject("properties").startObject("").field("type", type).endObject().endObject() .endObject().endObject().string(); IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> parser.parse("type", new CompressedXContent(mapping)) ); assertThat(e.getMessage(), containsString("name cannot be empty string")); } }
public MappingMetaData(String type, Map<String, Object> mapping) throws IOException { this.type = type; XContentBuilder mappingBuilder = XContentFactory.jsonBuilder().map(mapping); this.source = new CompressedXContent(BytesReference.bytes(mappingBuilder)); Map<String, Object> withoutType = mapping; if (mapping.size() == 1 && mapping.containsKey(type)) { withoutType = (Map<String, Object>) mapping.get(type); } initMappers(withoutType); }
public MappingMetaData(String type, Map<String, Object> mapping) throws IOException { this.type = type; XContentBuilder mappingBuilder = XContentFactory.jsonBuilder().map(mapping); this.source = new CompressedXContent(mappingBuilder.bytes()); Map<String, Object> withoutType = mapping; if (mapping.size() == 1 && mapping.containsKey(type)) { withoutType = (Map<String, Object>) mapping.get(type); } initMappers(withoutType); }
public MappingMetaData(String type, Map<String, Object> mapping) throws IOException { this.type = type; XContentBuilder mappingBuilder = XContentFactory.jsonBuilder().map(mapping); this.source = new CompressedXContent(mappingBuilder.bytes()); Map<String, Object> withoutType = mapping; if (mapping.size() == 1 && mapping.containsKey(type)) { withoutType = (Map<String, Object>) mapping.get(type); } initMappers(withoutType); }
public static CompressedXContent readCompressedString(StreamInput in) throws IOException { int crc32 = in.readInt(); byte[] compressed = new byte[in.readVInt()]; in.readBytes(compressed, 0, compressed.length); return new CompressedXContent(compressed, crc32); }
public static CompressedXContent readCompressedString(StreamInput in) throws IOException { int crc32 = in.readInt(); byte[] compressed = new byte[in.readVInt()]; in.readBytes(compressed, 0, compressed.length); return new CompressedXContent(compressed, crc32); }
public static CompressedXContent readCompressedString(StreamInput in) throws IOException { int crc32 = in.readInt(); byte[] compressed = new byte[in.readVInt()]; in.readBytes(compressed, 0, compressed.length); return new CompressedXContent(compressed, crc32); }
public static CompressedXContent readCompressedString(StreamInput in) throws IOException { int crc32 = in.readInt(); byte[] compressed = new byte[in.readVInt()]; in.readBytes(compressed, 0, compressed.length); return new CompressedXContent(compressed, crc32); }