Access to SearchSourceBuilder sourceBuilder for debugging

Hey,
Currently using the Java API and am building up a
SearchRequestBuilder object. I see that internally,
SearchRequestBuilder keeps a SearchSourceBuilder member(sourceBuilder)
that is private.

I would like to be able to provide some debug logging that would allow
a developer to copy and paste a curl command to run a query and debug.
In order to do this, I am currently instantiating my own
SearchSourceBuilder and calling the methods on it that
SearchRequestBuilder calls on its own internal sourceBuilder.

Afterwards, I instantiate a BinaryXContentBuilder and populate it with
a call like this:
BinaryXContentBuilder content = jsonBuilder();
debugSearchSource.toXContent(content, null);

And finally, get the search json with a call like:
content.string();

Is there anyway to get access to the SearchRequestBuilder's
sourceBuilder, so I don't have to mirror the method calls to my copy
or is there a better way to accomplish this that I have overlooked? A
debug method to get the SearchRequestBuilder sourceBuilder as string
or similar would be convenient for this case.

Thanks,
Paul

Pushed SearchRequestBuilder#internalBuilder(). Note, this should only be
used in debug mode, and only make sense when generation json and not the
binary smile format (on it I will post in a minute).

-shay.banon

On Tue, Sep 14, 2010 at 11:55 PM, Paul ppearcy@gmail.com wrote:

Hey,
Currently using the Java API and am building up a
SearchRequestBuilder object. I see that internally,
SearchRequestBuilder keeps a SearchSourceBuilder member(sourceBuilder)
that is private.

I would like to be able to provide some debug logging that would allow
a developer to copy and paste a curl command to run a query and debug.
In order to do this, I am currently instantiating my own
SearchSourceBuilder and calling the methods on it that
SearchRequestBuilder calls on its own internal sourceBuilder.

Afterwards, I instantiate a BinaryXContentBuilder and populate it with
a call like this:
BinaryXContentBuilder content = jsonBuilder();
debugSearchSource.toXContent(content, null);

And finally, get the search json with a call like:
content.string();

Is there anyway to get access to the SearchRequestBuilder's
sourceBuilder, so I don't have to mirror the method calls to my copy
or is there a better way to accomplish this that I have overlooked? A
debug method to get the SearchRequestBuilder sourceBuilder as string
or similar would be convenient for this case.

Thanks,
Paul

Great, thanks!

On Sep 15, 4:44 am, Shay Banon shay.ba...@elasticsearch.com wrote:

Pushed SearchRequestBuilder#internalBuilder(). Note, this should only be
used in debug mode, and only make sense when generation json and not the
binary smile format (on it I will post in a minute).

-shay.banon

On Tue, Sep 14, 2010 at 11:55 PM, Paul ppea...@gmail.com wrote:

Hey,
Currently using the Java API and am building up a
SearchRequestBuilder object. I see that internally,
SearchRequestBuilder keeps a SearchSourceBuilder member(sourceBuilder)
that is private.

I would like to be able to provide some debug logging that would allow
a developer to copy and paste a curl command to run a query and debug.
In order to do this, I am currently instantiating my own
SearchSourceBuilder and calling the methods on it that
SearchRequestBuilder calls on its own internal sourceBuilder.

Afterwards, I instantiate a BinaryXContentBuilder and populate it with
a call like this:
BinaryXContentBuilder content = jsonBuilder();
debugSearchSource.toXContent(content, null);

And finally, get the search json with a call like:
content.string();

Is there anyway to get access to the SearchRequestBuilder's
sourceBuilder, so I don't have to mirror the method calls to my copy
or is there a better way to accomplish this that I have overlooked? A
debug method to get the SearchRequestBuilder sourceBuilder as string
or similar would be convenient for this case.

Thanks,
Paul