Analyze API returns in YAML format if analyzed string begins with ---
fixes #2624
This commit is contained in:
parent
9b68e98ea2
commit
2eea99255d
|
@ -76,7 +76,7 @@ public class RestAnalyzeAction extends BaseRestHandler {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(AnalyzeResponse response) {
|
public void onResponse(AnalyzeResponse response) {
|
||||||
try {
|
try {
|
||||||
XContentBuilder builder = restContentBuilder(request);
|
XContentBuilder builder = restContentBuilder(request, false);
|
||||||
builder.startObject();
|
builder.startObject();
|
||||||
response.toXContent(builder, request);
|
response.toXContent(builder, request);
|
||||||
builder.endObject();
|
builder.endObject();
|
||||||
|
|
|
@ -35,10 +35,14 @@ import java.io.IOException;
|
||||||
public class RestXContentBuilder {
|
public class RestXContentBuilder {
|
||||||
|
|
||||||
public static XContentBuilder restContentBuilder(RestRequest request) throws IOException {
|
public static XContentBuilder restContentBuilder(RestRequest request) throws IOException {
|
||||||
|
return restContentBuilder(request, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static XContentBuilder restContentBuilder(RestRequest request, boolean autoDetect) throws IOException {
|
||||||
XContentType contentType = XContentType.fromRestContentType(request.param("format", request.header("Content-Type")));
|
XContentType contentType = XContentType.fromRestContentType(request.param("format", request.header("Content-Type")));
|
||||||
if (contentType == null) {
|
if (contentType == null) {
|
||||||
// try and guess it from the body, if exists
|
// try and guess it from the body, if exists
|
||||||
if (request.hasContent()) {
|
if (autoDetect && request.hasContent()) {
|
||||||
contentType = XContentFactory.xContentType(request.content());
|
contentType = XContentFactory.xContentType(request.content());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue