From 78608536e2962a09fe6a1718f7ec71bd2615eab3 Mon Sep 17 00:00:00 2001 From: javanna Date: Mon, 2 Mar 2015 12:38:51 +0100 Subject: [PATCH] Java api: SearchRequestBuilder#toString to print out the query without wiping the request source Best effort to print out the search source depending on how it was set to the SearchRequestBuilder, don't call `internalBuilder() as that causes the content of the request to be wiped. Closes #5576 --- .../action/search/SearchRequestBuilder.java | 17 ++- .../search/builder/SearchSourceBuilder.java | 3 +- .../search/SearchRequestBuilderTests.java | 128 ++++++++++++++++++ 3 files changed, 143 insertions(+), 5 deletions(-) create mode 100644 src/test/java/org/elasticsearch/action/search/SearchRequestBuilderTests.java diff --git a/src/main/java/org/elasticsearch/action/search/SearchRequestBuilder.java b/src/main/java/org/elasticsearch/action/search/SearchRequestBuilder.java index 59d6db804b0..e51bbb6234f 100644 --- a/src/main/java/org/elasticsearch/action/search/SearchRequestBuilder.java +++ b/src/main/java/org/elasticsearch/action/search/SearchRequestBuilder.java @@ -20,6 +20,7 @@ package org.elasticsearch.action.search; import org.elasticsearch.ElasticsearchIllegalArgumentException; +import org.elasticsearch.ExceptionsHelper; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.ActionRequestBuilder; import org.elasticsearch.action.support.IndicesOptions; @@ -28,6 +29,7 @@ import org.elasticsearch.common.Nullable; import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.xcontent.XContentBuilder; +import org.elasticsearch.common.xcontent.XContentHelper; import org.elasticsearch.index.query.FilterBuilder; import org.elasticsearch.index.query.QueryBuilder; import org.elasticsearch.script.ScriptService; @@ -366,9 +368,6 @@ public class SearchRequestBuilder extends ActionRequestBuilder