add toString to SearchRequestBuilder
This commit is contained in:
parent
10108d9a4e
commit
cb691ef54b
|
@ -574,6 +574,10 @@ public class SearchRequestBuilder extends BaseRequestBuilder<SearchRequest, Sear
|
|||
return sourceBuilder();
|
||||
}
|
||||
|
||||
@Override public String toString() {
|
||||
return internalBuilder().toString();
|
||||
}
|
||||
|
||||
@Override protected void doExecute(ActionListener<SearchResponse> listener) {
|
||||
request.source(sourceBuilder());
|
||||
client.search(request, listener);
|
||||
|
|
|
@ -380,6 +380,16 @@ public class SearchSourceBuilder implements ToXContent {
|
|||
return this;
|
||||
}
|
||||
|
||||
@Override public String toString() {
|
||||
try {
|
||||
XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON).prettyPrint();
|
||||
toXContent(builder, ToXContent.EMPTY_PARAMS);
|
||||
return builder.string();
|
||||
} catch (Exception e) {
|
||||
return "{ \"error\" : \"" + e.getMessage() + "\"}";
|
||||
}
|
||||
}
|
||||
|
||||
public FastByteArrayOutputStream buildAsUnsafeBytes(XContentType contentType) throws SearchSourceBuilderException {
|
||||
try {
|
||||
XContentBuilder builder = XContentFactory.contentBuilder(contentType);
|
||||
|
|
Loading…
Reference in New Issue