本文整理匯總了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;
}