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();
|
return sourceBuilder();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override public String toString() {
|
||||||
|
return internalBuilder().toString();
|
||||||
|
}
|
||||||
|
|
||||||
@Override protected void doExecute(ActionListener<SearchResponse> listener) {
|
@Override protected void doExecute(ActionListener<SearchResponse> listener) {
|
||||||
request.source(sourceBuilder());
|
request.source(sourceBuilder());
|
||||||
client.search(request, listener);
|
client.search(request, listener);
|
||||||
|
|
|
@ -380,6 +380,16 @@ public class SearchSourceBuilder implements ToXContent {
|
||||||
return this;
|
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 {
|
public FastByteArrayOutputStream buildAsUnsafeBytes(XContentType contentType) throws SearchSourceBuilderException {
|
||||||
try {
|
try {
|
||||||
XContentBuilder builder = XContentFactory.contentBuilder(contentType);
|
XContentBuilder builder = XContentFactory.contentBuilder(contentType);
|
||||||
|
|
Loading…
Reference in New Issue