How to get the json for a searchrequest?

Is there a way to get the json string from a SearchRequest object?

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/30e07de8-ed0c-49c9-a163-aaa11f20c9a4%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

If you mean in Java, toString() gives me the json representation.

-Amit.

On Mon, Mar 3, 2014 at 4:30 PM, Tebring Daly tdalytx@gmail.com wrote:

Is there a way to get the json string from a SearchRequest object?

--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/30e07de8-ed0c-49c9-a163-aaa11f20c9a4%40googlegroups.com
.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAAOGaQ%2BDVPw7dq2r%3DU1rNJzmLWaXHQZ1KsMRPbjBWqvj7_nQNQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

On a toString() I get the typical unimplemented toString class reference :
"org.elasticsearch.action.search.SearchRequest@142daa2e"

I am using elasticsearch 1.0.0, wonder if something has changed from 0.90
or 1.0.1?

Thanks for the response

On Monday, March 3, 2014 8:46:25 PM UTC-6, amit.soni wrote:

If you mean in Java, toString() gives me the json representation.

-Amit.

On Mon, Mar 3, 2014 at 4:30 PM, Tebring Daly <tda...@gmail.com<javascript:>

wrote:

Is there a way to get the json string from a SearchRequest object?

--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to elasticsearc...@googlegroups.com <javascript:>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/30e07de8-ed0c-49c9-a163-aaa11f20c9a4%40googlegroups.com
.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/61c3c936-08bd-423d-8a44-f26d08477dd1%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

I think you can print a QueryBuilder or a SearchRequestBuilder but not a SearchRequest.

	QueryBuilder qb = QueryBuilders.queryString("my text");
	logger.info("Your query is : {}", qb);

	// this works as well
	node.client().prepareSearch().setQuery(qb).toString();

--
David Pilato | Technical Advocate | Elasticsearch.com
@dadoonet | @elasticsearchfr

Le 4 mars 2014 à 17:45:56, Tebring Daly (tdalytx@gmail.com) a écrit:

On a toString() I get the typical unimplemented toString class reference : "org.elasticsearch.action.search.SearchRequest@142daa2e"

I am using elasticsearch 1.0.0, wonder if something has changed from 0.90 or 1.0.1?

Thanks for the response

On Monday, March 3, 2014 8:46:25 PM UTC-6, amit.soni wrote:
If you mean in Java, toString() gives me the json representation.

-Amit.

On Mon, Mar 3, 2014 at 4:30 PM, Tebring Daly tda...@gmail.com wrote:
Is there a way to get the json string from a SearchRequest object?

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/30e07de8-ed0c-49c9-a163-aaa11f20c9a4%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/61c3c936-08bd-423d-8a44-f26d08477dd1%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/etPan.53160504.2ae8944a.7701%40MacBook-Air-de-David.local.
For more options, visit https://groups.google.com/groups/opt_out.

Great! Thanks David!

On Tuesday, March 4, 2014 10:53:24 AM UTC-6, David Pilato wrote:

I think you can print a QueryBuilder or a SearchRequestBuilder but not a
SearchRequest.

QueryBuilder qb = QueryBuilders.queryString("my text");
logger.info("Your query is : {}", qb);

// this works as well
node.client().prepareSearch().setQuery(qb).toString();

--
David Pilato | Technical Advocate | Elasticsearch.com
@dadoonet https://twitter.com/dadoonet | @elasticsearchfrhttps://twitter.com/elasticsearchfr

Le 4 mars 2014 à 17:45:56, Tebring Daly (tda...@gmail.com <javascript:>)
a écrit:

On a toString() I get the typical unimplemented toString class reference :
"org.elasticsearch.action.search.SearchRequest@142daa2e"

I am using elasticsearch 1.0.0, wonder if something has changed from 0.90
or 1.0.1?

Thanks for the response

On Monday, March 3, 2014 8:46:25 PM UTC-6, amit.soni wrote:

If you mean in Java, toString() gives me the json representation.

-Amit.

On Mon, Mar 3, 2014 at 4:30 PM, Tebring Daly tda...@gmail.com wrote:

Is there a way to get the json string from a SearchRequest object?

--
You received this message because you are subscribed to the Google
Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to elasticsearc...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/30e07de8-ed0c-49c9-a163-aaa11f20c9a4%40googlegroups.com
.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to elasticsearc...@googlegroups.com <javascript:>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/61c3c936-08bd-423d-8a44-f26d08477dd1%40googlegroups.com
.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/091cff7c-d200-474f-becb-f6bb340af94e%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Is there really no way to print a search request?

Because QueryBuilder does not know about indices, or the fields we want the search request to return. And I'd like to have those fields in my JSon representation.

Basically I'd like to create a JSon representation that I can use as a source of a search request later on, like an editable template.

this is how to do it

            String json = XContentHelper.convertToJson(request.source(), true);
            LOG.info(json);
            json = XContentHelper.convertToJson(request.extraSource(), true);
            LOG.info(json);