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
|
||||
public void onResponse(AnalyzeResponse response) {
|
||||
try {
|
||||
XContentBuilder builder = restContentBuilder(request);
|
||||
XContentBuilder builder = restContentBuilder(request, false);
|
||||
builder.startObject();
|
||||
response.toXContent(builder, request);
|
||||
builder.endObject();
|
||||
|
|
|
@ -35,10 +35,14 @@ import java.io.IOException;
|
|||
public class RestXContentBuilder {
|
||||
|
||||
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")));
|
||||
if (contentType == null) {
|
||||
// try and guess it from the body, if exists
|
||||
if (request.hasContent()) {
|
||||
if (autoDetect && request.hasContent()) {
|
||||
contentType = XContentFactory.xContentType(request.content());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue