REST API: Allow to provide `case` parameter, with `camelCase` to return results in CamelCasing, closes #162.
This commit is contained in:
parent
e222d38b84
commit
31d226188f
|
@ -23,6 +23,7 @@ import org.elasticsearch.rest.RestRequest;
|
||||||
import org.elasticsearch.util.xcontent.XContentFactory;
|
import org.elasticsearch.util.xcontent.XContentFactory;
|
||||||
import org.elasticsearch.util.xcontent.XContentType;
|
import org.elasticsearch.util.xcontent.XContentType;
|
||||||
import org.elasticsearch.util.xcontent.builder.BinaryXContentBuilder;
|
import org.elasticsearch.util.xcontent.builder.BinaryXContentBuilder;
|
||||||
|
import org.elasticsearch.util.xcontent.builder.XContentBuilder;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
@ -47,6 +48,14 @@ public class RestXContentBuilder {
|
||||||
if (request.paramAsBoolean("pretty", false)) {
|
if (request.paramAsBoolean("pretty", false)) {
|
||||||
builder.prettyPrint();
|
builder.prettyPrint();
|
||||||
}
|
}
|
||||||
|
String casing = request.param("case");
|
||||||
|
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;
|
return builder;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue