static HttpEntity createEntity(ToXContent toXContent, XContentType xContentType) { try { BytesRef source = XContentHelper.toXContent(toXContent, xContentType, false).toBytesRef(); return new ByteArrayEntity(source.bytes, source.offset, source.length, createContentType(xContentType)); } catch (IOException e) { throw new RuntimeException(e); } }
/** * Returns the bytes that represent the XContent output of the provided {@link ToXContent} object, using the provided * {@link XContentType}. Wraps the output into a new anonymous object according to the value returned * by the {@link ToXContent#isFragment()} method returns. */ public static BytesReference toXContent(ToXContent toXContent, XContentType xContentType, boolean humanReadable) throws IOException { return toXContent(toXContent, xContentType, ToXContent.EMPTY_PARAMS, humanReadable); }
/** * Construct a {@linkplain TaskResult} for a task that completed successfully. */ public TaskResult(TaskInfo task, ToXContent response) throws IOException { this(true, task, null, XContentHelper.toXContent(response, Requests.INDEX_CONTENT_TYPE, true)); }
source = XContentHelper.toXContent((UpdateRequest) action, bulkContentType, false).toBytesRef();
private BytesReference toBytesReference(IndexTemplateMetaData templateMetaData) { try { return XContentHelper.toXContent((builder, params) -> { IndexTemplateMetaData.Builder.toInnerXContent(templateMetaData, builder, params); return builder; }, XContentType.JSON, PARAMS, false); } catch (IOException ex) { throw new IllegalStateException("Cannot serialize template [" + templateMetaData.getName() + "]", ex); } } }
public String toString(Params params) { try { return XContentHelper.toXContent(this, XContentType.JSON, params, true).utf8ToString(); } catch (IOException e) { throw new ElasticsearchException(e); } } }
private static void addFieldMapper(Predicate<String> fieldPredicate, String field, Mapper fieldMapper, Map<String, FieldMappingMetaData> fieldMappings, boolean includeDefaults) { if (fieldMappings.containsKey(field)) { return; } if (fieldPredicate.test(field)) { try { BytesReference bytes = XContentHelper.toXContent(fieldMapper, XContentType.JSON, includeDefaults ? includeDefaultsParams : ToXContent.EMPTY_PARAMS, false); fieldMappings.put(field, new FieldMappingMetaData(fieldMapper.name(), bytes)); } catch (IOException e) { throw new ElasticsearchException("failed to serialize XContent of field [" + field + "]", e); } } } }
/** * Returns the bytes that represent the XContent output of the provided {@link ToXContent} object, using the provided * {@link XContentType}. Wraps the output into a new anonymous object according to the value returned * by the {@link ToXContent#isFragment()} method returns. */ public static BytesReference toXContent(ToXContent toXContent, XContentType xContentType, boolean humanReadable) throws IOException { return toXContent(toXContent, xContentType, ToXContent.EMPTY_PARAMS, humanReadable); }
/** * Construct a {@linkplain TaskResult} for a task that completed successfully. */ public TaskResult(TaskInfo task, ToXContent response) throws IOException { this(true, task, null, XContentHelper.toXContent(response, Requests.INDEX_CONTENT_TYPE, true)); }
/** * Returns the bytes that represent the XContent output of the provided {@link ToXContent} object, using the provided * {@link XContentType}. Wraps the output into a new anonymous object according to the value returned * by the {@link ToXContent#isFragment()} method returns. */ public static BytesReference toXContent(ToXContent toXContent, XContentType xContentType, boolean humanReadable) throws IOException { return toXContent(toXContent, xContentType, ToXContent.EMPTY_PARAMS, humanReadable); }
/** * Construct a {@linkplain TaskResult} for a task that completed successfully. */ public TaskResult(TaskInfo task, ToXContent response) throws IOException { this(true, task, null, toXContent(response)); }
/** * Returns the bytes that represent the XContent output of the provided {@link ToXContent} object, using the provided * {@link XContentType}. Wraps the output into a new anonymous object according to the value returned * by the {@link ToXContent#isFragment()} method returns. */ public static BytesReference toXContent(ToXContent toXContent, XContentType xContentType, boolean humanReadable) throws IOException { return toXContent(toXContent, xContentType, ToXContent.EMPTY_PARAMS, humanReadable); }
@Override public String toString() { try { return XContentHelper.toXContent(this, XContentType.JSON, true).utf8ToString(); } catch (IOException e) { throw new RuntimeException("Unexpected", e); } }
@Override public String toString() { try { return XContentHelper.toXContent(this, XContentType.JSON, true).utf8ToString(); } catch (IOException e) { throw new UncheckedIOException("Unexpected", e); } }
@Override public String toString() { try { return XContentHelper.toXContent(this, XContentType.JSON, true).utf8ToString(); } catch (IOException e) { throw new RuntimeException("Unexpected", e); } }
static HttpEntity createEntity(ToXContent toXContent, XContentType xContentType, ToXContent.Params toXContentParams) throws IOException { BytesRef source = XContentHelper.toXContent(toXContent, xContentType, toXContentParams, false).toBytesRef(); return new ByteArrayEntity(source.bytes, source.offset, source.length, createContentType(xContentType)); }
private BytesReference toBytesReference(IndexTemplateMetaData templateMetaData) { try { return XContentHelper.toXContent((builder, params) -> { IndexTemplateMetaData.Builder.toInnerXContent(templateMetaData, builder, params); return builder; }, XContentType.JSON, PARAMS, false); } catch (IOException ex) { throw new IllegalStateException("Cannot serialize template [" + templateMetaData.getName() + "]", ex); } } }
private BytesReference toBytesReference(IndexTemplateMetaData templateMetaData) { try { return XContentHelper.toXContent((builder, params) -> { IndexTemplateMetaData.Builder.toInnerXContent(templateMetaData, builder, params); return builder; }, XContentType.JSON, PARAMS, false); } catch (IOException ex) { throw new IllegalStateException("Cannot serialize template [" + templateMetaData.getName() + "]", ex); } } }
public String toString(Params params) { try { return XContentHelper.toXContent(this, XContentType.JSON, params, true).utf8ToString(); } catch (IOException e) { throw new ElasticsearchException(e); } } }
public String toString(Params params) { try { return XContentHelper.toXContent(this, XContentType.JSON, params, true).utf8ToString(); } catch (IOException e) { throw new ElasticsearchException(e); } } }