本文整理汇总了Java中org.elasticsearch.common.xcontent.XContentBuilder.fieldCaseConversion方法的典型用法代码示例。如果您正苦于以下问题:Java XContentBuilder.fieldCaseConversion方法的具体用法?Java XContentBuilder.fieldCaseConversion怎么用?Java XContentBuilder.fieldCaseConversion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.elasticsearch.common.xcontent.XContentBuilder
的用法示例。
在下文中一共展示了XContentBuilder.fieldCaseConversion方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: restContentBuilder
import org.elasticsearch.common.xcontent.XContentBuilder; //导入方法依赖的package包/类
public static XContentBuilder restContentBuilder(RestRequest request)
throws IOException {
XContentType contentType = XContentType
.fromRestContentType(request.header("Content-Type"));
if (contentType == null) {
// try and guess it from the body, if exists
if (request.hasContent()) {
contentType = XContentFactory.xContentType(request.content());
}
}
if (contentType == null) {
// default to JSON
contentType = XContentType.JSON;
}
BytesStreamOutput out = new BytesStreamOutput();
XContentBuilder builder = new XContentBuilder(
XContentFactory.xContent(contentType), out);
if (request.paramAsBoolean("pretty", false)) {
builder.prettyPrint();
}
String casing = request.param("case");
if (casing != null && "camelCase".equals(casing)) {
builder.fieldCaseConversion(
XContentBuilder.FieldCaseConversion.CAMELCASE);
} else {
builder.fieldCaseConversion(
XContentBuilder.FieldCaseConversion.NONE);
}
return builder;
}
示例2: newBuilder
import org.elasticsearch.common.xcontent.XContentBuilder; //导入方法依赖的package包/类
public XContentBuilder newBuilder(@Nullable BytesReference autoDetectSource, boolean useFiltering) throws IOException {
XContentType contentType = XContentType.fromRestContentType(request.param("format", request.header("Content-Type")));
if (contentType == null) {
// try and guess it from the auto detect source
if (autoDetectSource != null) {
contentType = XContentFactory.xContentType(autoDetectSource);
}
}
if (contentType == null) {
// default to JSON
contentType = XContentType.JSON;
}
String[] filters = useFiltering ? request.paramAsStringArrayOrEmptyIfAll("filter_path") : null;
XContentBuilder builder = new XContentBuilder(XContentFactory.xContent(contentType), bytesOutput(), filters);
if (request.paramAsBoolean("pretty", false)) {
builder.prettyPrint().lfAtEnd();
}
builder.humanReadable(request.paramAsBoolean("human", builder.humanReadable()));
String casing = request.param("case");
if (casing != null) {
String msg = "Parameter 'case' has been deprecated, all responses will use underscore casing in the future";
DEPRECATION_LOGGER.deprecated(msg);
}
if (casing != null && "camelCase".equals(casing)) {
builder.fieldCaseConversion(XContentBuilder.FieldCaseConversion.CAMELCASE);
} else {
// we expect all REST interfaces to write results in underscore casing, so
// no need for double casing
builder.fieldCaseConversion(XContentBuilder.FieldCaseConversion.NONE);
}
return builder;
}