# SearchRequestBuilder to Json

**URL:** <https://discuss.elastic.co/t/searchrequestbuilder-to-json/11483>\
**Category:** Elasticsearch\
**Created:** [April 8, 2013, 7:53am UTC](https://discuss.elastic.co/t/searchrequestbuilder-to-json/11483 "2013-04-08T07:53:26Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pierre\_De\_Soyres](https://avatars.discourse-cdn.com/v4/letter/p/f14d63/32.png) [@Pierre\_De\_Soyres](https://discuss.elastic.co/u/Pierre_De_Soyres)\
**Post date:** [April 8, 2013, 7:53am UTC](https://discuss.elastic.co/t/searchrequestbuilder-to-json/11483/1 "2013-04-08T07:53:26Z")

</div>

Hello,

I would like to know if there is a way to transform a SearchQueryBuilder  
into its corresponding Json format.

When I use toString() on a SearchQueryBuilder I get a partial Json :  
{  
"from" : 0,  
"size" : 200,  
"query" : {  
"bool" : {  
"should" : [ {  
"wrapper" : {  
"query" :  
"eyJib29sIjp7Im11c3QiOlt7IndpbGRjYXJkIjp7InN0cmluZ0ZpZWxkIjoiKnZhbHVlMSoifX0seyJtYXRjaCI6eyJzdHJpbmdGaWVsZCI6InZhbHVlMSJ9fV19fQ=="  
}  
}, {  
"wrapper" : {  
"query" :  
"eyJib29sIjp7Im11c3QiOlt7IndpbGRjYXJkIjp7InN0cmluZ0ZpZWxkIjoiKnZhbHVlMioifX0seyJtYXRjaCI6eyJzdHJpbmdGaWVsZCI6InZhbHVlMiJ9fV19fQ=="  
}  
} ]  
}  
},  
"fields" : ["body"]  
}

Can I have the full Json ?

Thanks in advance.  
Pierre.

--  
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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [April 8, 2013, 7:59am UTC](https://discuss.elastic.co/t/searchrequestbuilder-to-json/11483/2 "2013-04-08T07:59:23Z")

</div>

Hi Pierre,

Why do you think it's partial?  
What is missing here?

## David

David Pilato | Technical Advocate | [Elasticsearch.com](http://Elasticsearch.com)  
@dadoonet | @elasticsearchfr | @scrutmydocs

Le 8 avr. 2013 à 09:53, Pierre De Soyres [pierre.de-soyres@eptica.com](mailto:pierre.de-soyres@eptica.com) a écrit :

> Hello,
> 
> I would like to know if there is a way to transform a SearchQueryBuilder into its corresponding Json format.
> 
> When I use toString() on a SearchQueryBuilder I get a partial Json :  
> {  
> "from" : 0,  
> "size" : 200,  
> "query" : {  
> "bool" : {  
> "should" : [ {  
> "wrapper" : {  
> "query" : "eyJib29sIjp7Im11c3QiOlt7IndpbGRjYXJkIjp7InN0cmluZ0ZpZWxkIjoiKnZhbHVlMSoifX0seyJtYXRjaCI6eyJzdHJpbmdGaWVsZCI6InZhbHVlMSJ9fV19fQ=="  
> }  
> }, {  
> "wrapper" : {  
> "query" : "eyJib29sIjp7Im11c3QiOlt7IndpbGRjYXJkIjp7InN0cmluZ0ZpZWxkIjoiKnZhbHVlMioifX0seyJtYXRjaCI6eyJzdHJpbmdGaWVsZCI6InZhbHVlMiJ9fV19fQ=="  
> }  
> } ]  
> }  
> },  
> "fields" : ["body"]  
> }
> 
> Can I have the full Json ?
> 
> Thanks in advance.  
> Pierre.
> 
> --  
> 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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Pierre\_De\_Soyres](https://avatars.discourse-cdn.com/v4/letter/p/f14d63/32.png) [@Pierre\_De\_Soyres](https://discuss.elastic.co/u/Pierre_De_Soyres)\
**Post date:** [April 8, 2013, 8:02am UTC](https://discuss.elastic.co/t/searchrequestbuilder-to-json/11483/3 "2013-04-08T08:02:47Z")

</div>

Hi David,

I would klike to decode the wrapper part :  
"wrapper" : {  
"query" :  
"eyJib29sIjp7Im11c3QiOlt7IndpbGRjYXJkIjp7InN0cmluZ0ZpZWxkIjoiKnZhbHVlMSoifX0seyJtYXRjaCI6eyJzdHJpbmdGaWVsZCI6InZhbHVlMSJ9fV19fQ=="  
}

I don't understand this format

Pierre

Le lundi 8 avril 2013 09:59:23 UTC+2, David Pilato a écrit :

> Hi Pierre,
> 
> Why do you think it's partial?  
> What is missing here?
> 
> ## David
> 
> _David Pilato_ | _Technical Advocate_ | _[Elasticsearch.com](http://Elasticsearch.com)_  
> @dadoonet [https://twitter.com/dadoonet](https://twitter.com/dadoonet) | @elasticsearchfr[https://twitter.com/elasticsearchfr](https://twitter.com/elasticsearchfr)  
> | @scrutmydocs [https://twitter.com/scrutmydocs](https://twitter.com/scrutmydocs)
> 
> Le 8 avr. 2013 à 09:53, Pierre De Soyres \<[pierre.d...@eptica.com](mailto:pierre.d...@eptica.com)\<javascript:\>\>  
> a écrit :
> 
> Hello,
> 
> I would like to know if there is a way to transform a SearchQueryBuilder  
> into its corresponding Json format.
> 
> When I use toString() on a SearchQueryBuilder I get a partial Json :  
> {  
> "from" : 0,  
> "size" : 200,  
> "query" : {  
> "bool" : {  
> "should" : [ {  
> "wrapper" : {  
> "query" :  
> "eyJib29sIjp7Im11c3QiOlt7IndpbGRjYXJkIjp7InN0cmluZ0ZpZWxkIjoiKnZhbHVlMSoifX0seyJtYXRjaCI6eyJzdHJpbmdGaWVsZCI6InZhbHVlMSJ9fV19fQ=="  
> }  
> }, {  
> "wrapper" : {  
> "query" :  
> "eyJib29sIjp7Im11c3QiOlt7IndpbGRjYXJkIjp7InN0cmluZ0ZpZWxkIjoiKnZhbHVlMioifX0seyJtYXRjaCI6eyJzdHJpbmdGaWVsZCI6InZhbHVlMiJ9fV19fQ=="  
> }  
> } ]  
> }  
> },  
> "fields" : ["body"]  
> }
> 
> Can I have the full Json ?
> 
> Thanks in advance.  
> Pierre.
> 
> --  
> 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](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> For more options, visit [https://groups.google.com/groups/opt\_out](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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [April 8, 2013, 8:08am UTC](https://discuss.elastic.co/t/searchrequestbuilder-to-json/11483/4 "2013-04-08T08:08:10Z")

</div>

So do I.

What is your initial request (in Java)?

--  
David Pilato | Technical Advocate | [Elasticsearch.com](http://Elasticsearch.com)  
@dadoonet | @elasticsearchfr | @scrutmydocs

Le 8 avr. 2013 à 10:02, Pierre De Soyres [pierre.de-soyres@eptica.com](mailto:pierre.de-soyres@eptica.com) a écrit :

> Hi David,
> 
> I would klike to decode the wrapper part :  
> "wrapper" : {  
> "query" : "eyJib29sIjp7Im11c3QiOlt7IndpbGRjYXJkIjp7InN0cmluZ0ZpZWxkIjoiKnZhbHVlMSoifX0seyJtYXRjaCI6eyJzdHJpbmdGaWVsZCI6InZhbHVlMSJ9fV19fQ=="  
> }
> 
> I don't understand this format
> 
> Pierre
> 
> Le lundi 8 avril 2013 09:59:23 UTC+2, David Pilato a écrit :  
> Hi Pierre,
> 
> Why do you think it's partial?  
> What is missing here?
> 
> ## David
> 
> David Pilato | Technical Advocate | [Elasticsearch.com](http://Elasticsearch.com)  
> @dadoonet | @elasticsearchfr | @scrutmydocs
> 
> Le 8 avr. 2013 à 09:53, Pierre De Soyres [pierre.d...@eptica.com](mailto:pierre.d...@eptica.com) a écrit :
> 
> > Hello,
> > 
> > I would like to know if there is a way to transform a SearchQueryBuilder into its corresponding Json format.
> > 
> > When I use toString() on a SearchQueryBuilder I get a partial Json :  
> > {  
> > "from" : 0,  
> > "size" : 200,  
> > "query" : {  
> > "bool" : {  
> > "should" : [ {  
> > "wrapper" : {  
> > "query" : "eyJib29sIjp7Im11c3QiOlt7IndpbGRjYXJkIjp7InN0cmluZ0ZpZWxkIjoiKnZhbHVlMSoifX0seyJtYXRjaCI6eyJzdHJpbmdGaWVsZCI6InZhbHVlMSJ9fV19fQ=="  
> > }  
> > }, {  
> > "wrapper" : {  
> > "query" : "eyJib29sIjp7Im11c3QiOlt7IndpbGRjYXJkIjp7InN0cmluZ0ZpZWxkIjoiKnZhbHVlMioifX0seyJtYXRjaCI6eyJzdHJpbmdGaWVsZCI6InZhbHVlMiJ9fV19fQ=="  
> > }  
> > } ]  
> > }  
> > },  
> > "fields" : ["body"]  
> > }
> > 
> > Can I have the full Json ?
> > 
> > Thanks in advance.  
> > Pierre.
> > 
> > --  
> > 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](mailto:elasticsearc...@googlegroups.com).  
> > For more options, visit [https://groups.google.com/groups/opt\_out](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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Pierre\_De\_Soyres](https://avatars.discourse-cdn.com/v4/letter/p/f14d63/32.png) [@Pierre\_De\_Soyres](https://discuss.elastic.co/u/Pierre_De_Soyres)\
**Post date:** [April 8, 2013, 9:46am UTC](https://discuss.elastic.co/t/searchrequestbuilder-to-json/11483/5 "2013-04-08T09:46:23Z")

</div>

It is a WrapperQueryBuilder. I understand that the value of the "query"  
param is the initial Json Base64 encoded.

Le lundi 8 avril 2013 10:08:10 UTC+2, David Pilato a écrit :

> So do I.
> 
> What is your initial request (in Java)?
> 
> --  
> _David Pilato_ | _Technical Advocate_ | _[Elasticsearch.com](http://Elasticsearch.com)_  
> @dadoonet [https://twitter.com/dadoonet](https://twitter.com/dadoonet) | @elasticsearchfr[https://twitter.com/elasticsearchfr](https://twitter.com/elasticsearchfr)  
> | @scrutmydocs [https://twitter.com/scrutmydocs](https://twitter.com/scrutmydocs)
> 
> Le 8 avr. 2013 à 10:02, Pierre De Soyres \<[pierre.d...@eptica.com](mailto:pierre.d...@eptica.com)\<javascript:\>\>  
> a écrit :
> 
> Hi David,
> 
> I would klike to decode the wrapper part :  
> "wrapper" : {  
> "query" :  
> "eyJib29sIjp7Im11c3QiOlt7IndpbGRjYXJkIjp7InN0cmluZ0ZpZWxkIjoiKnZhbHVlMSoifX0seyJtYXRjaCI6eyJzdHJpbmdGaWVsZCI6InZhbHVlMSJ9fV19fQ=="  
> }
> 
> I don't understand this format
> 
> Pierre
> 
> Le lundi 8 avril 2013 09:59:23 UTC+2, David Pilato a écrit :
> 
> > Hi Pierre,
> > 
> > Why do you think it's partial?  
> > What is missing here?
> > 
> > ## David
> > 
> > _David Pilato_ | _Technical Advocate_ | \*[Elasticsearch.com](http://Elasticsearch.com)[http://elasticsearch.com/](http://elasticsearch.com/)  
> > \*  
> > @dadoonet [https://twitter.com/dadoonet](https://twitter.com/dadoonet) | @elasticsearchfr[https://twitter.com/elasticsearchfr](https://twitter.com/elasticsearchfr)  
> > | @scrutmydocs [https://twitter.com/scrutmydocs](https://twitter.com/scrutmydocs)
> > 
> > Le 8 avr. 2013 à 09:53, Pierre De Soyres [pierre.d...@eptica.com](mailto:pierre.d...@eptica.com) a  
> > écrit :
> > 
> > Hello,
> > 
> > I would like to know if there is a way to transform a SearchQueryBuilder  
> > into its corresponding Json format.
> > 
> > When I use toString() on a SearchQueryBuilder I get a partial Json :  
> > {  
> > "from" : 0,  
> > "size" : 200,  
> > "query" : {  
> > "bool" : {  
> > "should" : [ {  
> > "wrapper" : {  
> > "query" :  
> > "eyJib29sIjp7Im11c3QiOlt7IndpbGRjYXJkIjp7InN0cmluZ0ZpZWxkIjoiKnZhbHVlMSoifX0seyJtYXRjaCI6eyJzdHJpbmdGaWVsZCI6InZhbHVlMSJ9fV19fQ=="  
> > }  
> > }, {  
> > "wrapper" : {  
> > "query" :  
> > "eyJib29sIjp7Im11c3QiOlt7IndpbGRjYXJkIjp7InN0cmluZ0ZpZWxkIjoiKnZhbHVlMioifX0seyJtYXRjaCI6eyJzdHJpbmdGaWVsZCI6InZhbHVlMiJ9fV19fQ=="  
> > }  
> > } ]  
> > }  
> > },  
> > "fields" : ["body"]  
> > }
> > 
> > Can I have the full Json ?
> > 
> > Thanks in advance.  
> > Pierre.
> > 
> > --  
> > 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](mailto:elasticsearc...@googlegroups.com).  
> > For more options, visit [https://groups.google.com/groups/opt\_out](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](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> For more options, visit [https://groups.google.com/groups/opt\_out](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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [April 8, 2013, 1:21pm UTC](https://discuss.elastic.co/t/searchrequestbuilder-to-json/11483/6 "2013-04-08T13:21:41Z")

</div>

I never used a WrapperQueryBuilder.  
How do you add your JSON query in it? String? Binary?  
If you are using binary content, it looks fine to me that Elasticsearch display your query as you sent it.

Do you really need to use a WrapperQuery?

## My 2 cents

David Pilato | Technical Advocate | [Elasticsearch.com](http://Elasticsearch.com)  
@dadoonet | @elasticsearchfr | @scrutmydocs

Le 8 avr. 2013 à 11:46, Pierre De Soyres [pierre.de-soyres@eptica.com](mailto:pierre.de-soyres@eptica.com) a écrit :

> WrapperQueryBuilder

--  
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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 2:42am UTC](https://discuss.elastic.co/t/searchrequestbuilder-to-json/11483/7 "2017-07-06T02:42:15Z")

</div>


