本文整理汇总了Java中org.elasticsearch.common.xcontent.XContentBuilder.contentType方法的典型用法代码示例。如果您正苦于以下问题:Java XContentBuilder.contentType方法的具体用法?Java XContentBuilder.contentType怎么用?Java XContentBuilder.contentType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.elasticsearch.common.xcontent.XContentBuilder
的用法示例。
在下文中一共展示了XContentBuilder.contentType方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Item
import org.elasticsearch.common.xcontent.XContentBuilder; //导入方法依赖的package包/类
/**
* Constructor for an artificial document request, that is not present in the index.
*
* @param index the index to be used for parsing the doc
* @param type the type to be used for parsing the doc
* @param doc the document specification
*/
public Item(@Nullable String index, @Nullable String type, XContentBuilder doc) {
if (doc == null) {
throw new IllegalArgumentException("Item requires doc to be non-null");
}
this.index = index;
this.type = type;
this.doc = doc.bytes();
this.xContentType = doc.contentType();
}
示例2: scriptFieldToXContent
import org.elasticsearch.common.xcontent.XContentBuilder; //导入方法依赖的package包/类
@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;
}
示例3: toXContent
import org.elasticsearch.common.xcontent.XContentBuilder; //导入方法依赖的package包/类
@Override
public final XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject(getName());
if (this.metaData != null) {
builder.field("meta", this.metaData);
}
builder.field(type);
internalXContent(builder, params);
if (aggregations != null || aggregationsBinary != null) {
if (aggregations != null) {
builder.startObject("aggregations");
for (AbstractAggregationBuilder subAgg : aggregations) {
subAgg.toXContent(builder, params);
}
builder.endObject();
}
if (aggregationsBinary != null) {
if (XContentFactory.xContentType(aggregationsBinary) == builder.contentType()) {
builder.rawField("aggregations", aggregationsBinary);
} else {
builder.field("aggregations_binary", aggregationsBinary);
}
}
}
return builder.endObject();
}
示例4: innerToXContent
import org.elasticsearch.common.xcontent.XContentBuilder; //导入方法依赖的package包/类
public void innerToXContent(XContentBuilder builder, Params params) throws IOException {
if (queryBuilder != null) {
builder.field("query");
queryBuilder.toXContent(builder, params);
}
if (queryBinary != null) {
if (XContentFactory.xContentType(queryBinary) == builder.contentType()) {
builder.rawField("query", queryBinary);
} else {
builder.field("query_binary", queryBinary);
}
}
}