本文整理了Java中org.elasticsearch.common.xcontent.XContentBuilder.rawValue()
方法的一些代码示例,展示了XContentBuilder.rawValue()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XContentBuilder.rawValue()
方法的具体详情如下:
包路径:org.elasticsearch.common.xcontent.XContentBuilder
类名称:XContentBuilder
方法名:rawValue
[英]Writes a value with the source coming directly from the bytes
[中]使用直接来自字节的源写入值
代码示例来源:origin: floragunncom/search-guard
private static String convertToYaml(String type, BytesReference bytes, boolean prettyPrint) throws IOException {
try (XContentParser parser = JsonXContent.jsonXContent.createParser(NamedXContentRegistry.EMPTY, SearchGuardDeprecationHandler.INSTANCE, bytes.streamInput())) {
parser.nextToken();
parser.nextToken();
if(!type.equals((parser.currentName()))) {
return null;
}
parser.nextToken();
XContentBuilder builder = XContentFactory.yamlBuilder();
if (prettyPrint) {
builder.prettyPrint();
}
builder.rawValue(new ByteArrayInputStream(parser.binaryValue()), XContentType.YAML);
return Strings.toString(builder);
}
}
代码示例来源:origin: org.elasticsearch/elasticsearch
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
if (source != null) {
builder.rawValue(source.streamInput(), xContentType);
} else {
builder.startObject().endObject();
}
return builder;
}
}
代码示例来源:origin: org.elasticsearch/elasticsearch
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.rawValue(source.streamInput(), xContentType);
return builder;
}
代码示例来源:origin: org.elasticsearch/elasticsearch
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
if (source != null) {
try (InputStream stream = new BytesArray(source).streamInput()) {
builder.rawValue(stream, XContentType.JSON);
}
} else {
builder.startObject().endObject();
}
return builder;
}
}
代码示例来源:origin: org.elasticsearch/elasticsearch
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
try (InputStream stream = status.streamInput()) {
return builder.rawValue(stream, XContentHelper.xContentType(status));
}
}
代码示例来源:origin: org.elasticsearch/elasticsearch
@Override
public RestResponse buildResponse(final GetResponse response) throws Exception {
checkResource(response);
final XContentBuilder builder = channel.newBuilder(request.getXContentType(), false);
final BytesReference source = response.getSourceInternal();
try (InputStream stream = source.streamInput()) {
builder.rawValue(stream, XContentHelper.xContentType(source));
}
return new BytesRestResponse(OK, builder);
}
代码示例来源:origin: com.strapdata.elasticsearch/elasticsearch
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
return builder.rawValue(status);
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
if (source != null) {
builder.rawValue(source.streamInput(), xContentType);
} else {
builder.startObject().endObject();
}
return builder;
}
}
代码示例来源:origin: apache/servicemix-bundles
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
if (source != null) {
builder.rawValue(source.streamInput(), xContentType);
} else {
builder.startObject().endObject();
}
return builder;
}
}
代码示例来源:origin: org.elasticsearch.client/elasticsearch-rest-high-level-client
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
try (InputStream stream = preview.streamInput()) {
builder.rawValue(stream, XContentType.JSON);
}
return builder;
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.rawValue(source.streamInput(), xContentType);
return builder;
}
代码示例来源:origin: apache/servicemix-bundles
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.rawValue(source.streamInput(), xContentType);
return builder;
}
代码示例来源:origin: apache/servicemix-bundles
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
if (source != null) {
try (InputStream stream = new BytesArray(source).streamInput()) {
builder.rawValue(stream, XContentType.JSON);
}
} else {
builder.startObject().endObject();
}
return builder;
}
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
if (source != null) {
try (InputStream stream = new BytesArray(source).streamInput()) {
builder.rawValue(stream, XContentType.JSON);
}
} else {
builder.startObject().endObject();
}
return builder;
}
}
代码示例来源:origin: apache/servicemix-bundles
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
try (InputStream stream = status.streamInput()) {
return builder.rawValue(stream, XContentHelper.xContentType(status));
}
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
try (InputStream stream = status.streamInput()) {
return builder.rawValue(stream, XContentHelper.xContentType(status));
}
}
代码示例来源:origin: harbby/presto-connectors
@Override
public RestResponse buildResponse(GetResponse response) throws Exception {
XContentBuilder builder = channel.newBuilder(response.getSourceInternal(), false);
if (!response.isExists()) {
return new BytesRestResponse(NOT_FOUND, builder);
} else {
builder.rawValue(response.getSourceInternal());
return new BytesRestResponse(OK, builder);
}
}
});
代码示例来源:origin: com.floragunn/search-guard-6
private static String convertToYaml(String type, BytesReference bytes, boolean prettyPrint) throws IOException {
try (XContentParser parser = JsonXContent.jsonXContent.createParser(NamedXContentRegistry.EMPTY, SearchGuardDeprecationHandler.INSTANCE, bytes.streamInput())) {
parser.nextToken();
parser.nextToken();
if(!type.equals((parser.currentName()))) {
return null;
}
parser.nextToken();
XContentBuilder builder = XContentFactory.yamlBuilder();
if (prettyPrint) {
builder.prettyPrint();
}
builder.rawValue(new ByteArrayInputStream(parser.binaryValue()), XContentType.YAML);
return Strings.toString(builder);
}
}
内容来源于网络,如有侵权,请联系作者删除!