本文整理了Java中org.elasticsearch.common.xcontent.XContentBuilder.rawField()
方法的一些代码示例,展示了XContentBuilder.rawField()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XContentBuilder.rawField()
方法的具体详情如下:
包路径:org.elasticsearch.common.xcontent.XContentBuilder
类名称:XContentBuilder
方法名:rawField
[英]Writes a raw field with the value taken from the bytes in the stream
[中]使用流中字节的值写入原始字段
代码示例来源:origin: org.elasticsearch/elasticsearch
/**
* Writes a "raw" (bytes) field, handling cases where the bytes are compressed, and tries to optimize writing using
* {@link XContentBuilder#rawField(String, InputStream, XContentType)}.
*/
public static void writeRawField(String field, BytesReference source, XContentType xContentType, XContentBuilder builder,
ToXContent.Params params) throws IOException {
Objects.requireNonNull(xContentType);
Compressor compressor = CompressorFactory.compressor(source);
if (compressor != null) {
try (InputStream compressedStreamInput = compressor.streamInput(source.streamInput())) {
builder.rawField(field, compressedStreamInput, xContentType);
}
} else {
try (InputStream stream = source.streamInput()) {
builder.rawField(field, stream, xContentType);
}
}
}
代码示例来源:origin: org.elasticsearch/elasticsearch
/**
* Writes a "raw" (bytes) field, handling cases where the bytes are compressed, and tries to optimize writing using
* {@link XContentBuilder#rawField(String, InputStream)}.
* @deprecated use {@link #writeRawField(String, BytesReference, XContentType, XContentBuilder, Params)} to avoid content type
* auto-detection
*/
@Deprecated
public static void writeRawField(String field, BytesReference source, XContentBuilder builder,
ToXContent.Params params) throws IOException {
Compressor compressor = CompressorFactory.compressor(source);
if (compressor != null) {
try (InputStream compressedStreamInput = compressor.streamInput(source.streamInput())) {
builder.rawField(field, compressedStreamInput);
}
} else {
try (InputStream stream = source.streamInput()) {
builder.rawField(field, stream);
}
}
}
代码示例来源:origin: org.elasticsearch/elasticsearch
public XContentBuilder innerToXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject(SETTINGS.getPreferredName());
settings.toXContent(builder, params);
builder.endObject();
builder.startObject(MAPPINGS.getPreferredName());
for (Map.Entry<String, String> entry : mappings.entrySet()) {
try (InputStream stream = new BytesArray(entry.getValue()).streamInput()) {
builder.rawField(entry.getKey(), stream, XContentType.JSON);
}
}
builder.endObject();
builder.startObject(ALIASES.getPreferredName());
for (Alias alias : aliases) {
alias.toXContent(builder, params);
}
builder.endObject();
return builder;
}
}
代码示例来源:origin: org.elasticsearch/elasticsearch
@Override
public void doXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject(getName());
try (InputStream stream = functionBytes.streamInput()) {
builder.rawField(fieldName, stream);
}
builder.field(DecayFunctionParser.MULTI_VALUE_MODE.getPreferredName(), multiValueMode.name());
builder.endObject();
}
代码示例来源:origin: org.elasticsearch/elasticsearch
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject(name);
if (filter != null) {
try (InputStream stream = new BytesArray(filter).streamInput()) {
builder.rawField(FILTER.getPreferredName(), stream, XContentType.JSON);
}
}
if (indexRouting != null && indexRouting.equals(searchRouting)) {
builder.field(ROUTING.getPreferredName(), indexRouting);
} else {
if (indexRouting != null) {
builder.field(INDEX_ROUTING.getPreferredName(), indexRouting);
}
if (searchRouting != null) {
builder.field(SEARCH_ROUTING.getPreferredName(), searchRouting);
}
}
builder.field(IS_WRITE_INDEX.getPreferredName(), writeIndex);
builder.endObject();
return builder;
}
代码示例来源:origin: org.elasticsearch/elasticsearch
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.field(FULL_NAME.getPreferredName(), fullName);
if (params.paramAsBoolean("pretty", false)) {
builder.field("mapping", sourceAsMap());
} else {
try (InputStream stream = source.streamInput()) {
builder.rawField(MAPPING.getPreferredName(), stream, XContentType.JSON);
}
}
return builder;
}
代码示例来源:origin: org.elasticsearch/elasticsearch
@Override
protected XContentBuilder innerToXContent(XContentBuilder builder, Params params) throws IOException {
if (fuzzyOptions != null) {
fuzzyOptions.toXContent(builder, params);
}
if (regexOptions != null) {
regexOptions.toXContent(builder, params);
}
if (skipDuplicates) {
builder.field(SKIP_DUPLICATES_FIELD.getPreferredName(), skipDuplicates);
}
if (contextBytes != null) {
try (InputStream stream = contextBytes.streamInput()) {
builder.rawField(CONTEXTS_FIELD.getPreferredName(), stream);
}
}
return builder;
}
代码示例来源:origin: org.elasticsearch/elasticsearch
if (contentType != null && builder.contentType().mediaType().equals(contentType)) {
try (InputStream stream = new BytesArray(idOrCode).streamInput()) {
builder.rawField(SOURCE_PARSE_FIELD.getPreferredName(), stream);
代码示例来源:origin: org.elasticsearch/elasticsearch
builder.rawField(FILTER.getPreferredName(), stream, XContentType.JSON);
代码示例来源:origin: org.elasticsearch/elasticsearch
builder.rawField(DOC.getPreferredName(), stream, xContentType);
代码示例来源:origin: com.strapdata.elasticsearch/elasticsearch
@Override
public void doXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject(getName());
builder.rawField(fieldName, functionBytes);
builder.field(DecayFunctionParser.MULTI_VALUE_MODE.getPreferredName(), multiValueMode.name());
builder.endObject();
}
代码示例来源:origin: apache/servicemix-bundles
@Override
public void doXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject(getName());
try (InputStream stream = functionBytes.streamInput()) {
builder.rawField(fieldName, stream);
}
builder.field(DecayFunctionParser.MULTI_VALUE_MODE.getPreferredName(), multiValueMode.name());
builder.endObject();
}
代码示例来源:origin: com.strapdata.elasticsearch/elasticsearch
@Override
protected XContentBuilder innerToXContent(XContentBuilder builder, Params params) throws IOException {
if (fuzzyOptions != null) {
fuzzyOptions.toXContent(builder, params);
}
if (regexOptions != null) {
regexOptions.toXContent(builder, params);
}
if (contextBytes != null) {
builder.rawField(CONTEXTS_FIELD.getPreferredName(), contextBytes);
}
return builder;
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch
@Override
public void doXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject(getName());
try (InputStream stream = functionBytes.streamInput()) {
builder.rawField(fieldName, stream);
}
builder.field(DecayFunctionParser.MULTI_VALUE_MODE.getPreferredName(), multiValueMode.name());
builder.endObject();
}
代码示例来源:origin: jprante/elasticsearch-transport-websocket
public NettyInteractiveResponse(String type, XContentBuilder builder) throws IOException {
this.type = type;
XContentBuilder responseBuilder = jsonBuilder()
.startObject().field("success", true).field("type", type);
if (builder != null) {
responseBuilder.rawField("data", builder.bytes());
}
responseBuilder.endObject();
this.response = new TextWebSocketFrame(responseBuilder.string());
}
代码示例来源:origin: com.strapdata.elasticsearch/elasticsearch
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.field("full_name", fullName);
if (params.paramAsBoolean("pretty", false)) {
builder.field("mapping", sourceAsMap());
} else {
builder.rawField("mapping", source, XContentType.JSON);
}
return builder;
}
}
代码示例来源:origin: harbby/presto-connectors
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.field("full_name", fullName);
if (params.paramAsBoolean("pretty", false)) {
builder.field("mapping", sourceAsMap());
} else {
builder.rawField("mapping", source);
}
return builder;
}
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.field(FULL_NAME.getPreferredName(), fullName);
if (params.paramAsBoolean("pretty", false)) {
builder.field("mapping", sourceAsMap());
} else {
try (InputStream stream = source.streamInput()) {
builder.rawField(MAPPING.getPreferredName(), stream, XContentType.JSON);
}
}
return builder;
}
代码示例来源:origin: apache/servicemix-bundles
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.field(FULL_NAME.getPreferredName(), fullName);
if (params.paramAsBoolean("pretty", false)) {
builder.field("mapping", sourceAsMap());
} else {
try (InputStream stream = source.streamInput()) {
builder.rawField(MAPPING.getPreferredName(), stream, XContentType.JSON);
}
}
return builder;
}
代码示例来源:origin: harbby/presto-connectors
@Override
protected XContentBuilder scriptFieldToXContent(String template, ScriptType type, XContentBuilder builder, Params builderParams)
throws IOException {
if (type == ScriptType.INLINE && contentType != null && builder.contentType() == contentType) {
builder.rawField(type.getParseField().getPreferredName(), new BytesArray(template));
} else {
builder.field(type.getParseField().getPreferredName(), template);
}
return builder;
}
内容来源于网络,如有侵权,请联系作者删除!