Add a toString() method to MultiSearchResponse
This commit is contained in:
parent
840eaf983d
commit
b2597b5316
|
@ -9,6 +9,7 @@ import org.elasticsearch.common.io.stream.Streamable;
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
import org.elasticsearch.common.xcontent.ToXContent;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilderString;
|
import org.elasticsearch.common.xcontent.XContentBuilderString;
|
||||||
|
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
@ -168,4 +169,17 @@ public class MultiSearchResponse extends ActionResponse implements Iterable<Mult
|
||||||
static final XContentBuilderString RESPONSES = new XContentBuilderString("responses");
|
static final XContentBuilderString RESPONSES = new XContentBuilderString("responses");
|
||||||
static final XContentBuilderString ERROR = new XContentBuilderString("error");
|
static final XContentBuilderString ERROR = new XContentBuilderString("error");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
try {
|
||||||
|
XContentBuilder builder = XContentFactory.jsonBuilder().prettyPrint();
|
||||||
|
builder.startObject();
|
||||||
|
toXContent(builder, EMPTY_PARAMS);
|
||||||
|
builder.endObject();
|
||||||
|
return builder.string();
|
||||||
|
} catch (IOException e) {
|
||||||
|
return "{ \"error\" : \"" + e.getMessage() + "\"}";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue