# Parse JSON string to BooleanQueryBuilder

**URL:** <https://discuss.elastic.co/t/parse-json-string-to-booleanquerybuilder/3803>\
**Category:** Elasticsearch\
**Created:** [January 18, 2011, 2:00pm UTC](https://discuss.elastic.co/t/parse-json-string-to-booleanquerybuilder/3803 "2011-01-18T14:00:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![srrin](https://avatars.discourse-cdn.com/v4/letter/s/85f322/32.png) [@srrin](https://discuss.elastic.co/u/srrin)\
**Post date:** [January 18, 2011, 2:00pm UTC](https://discuss.elastic.co/t/parse-json-string-to-booleanquerybuilder/3803/1 "2011-01-18T14:00:56Z")

</div>

Hi  
I need to parse a Json query to booleanquerybuilder. But I am not sure how to achieve this via Java api.  
For e.g  
{ "bool" : { "must" : { "term" : { "author": "xyz" } } ,"must" : { "has\_child" : {"type" : "person", "query" :{ "term" : { "name": "abc" } }} } ,"must" : { "has\_child" : {"type" : "county", "query" :{ "term" : { "city": "ny" } }} } } }

I need to parse the above json query to BooleanQueryBuilder. Can anyone help me how to achieve this?  
Thanks in advance.

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [January 18, 2011, 6:28pm UTC](https://discuss.elastic.co/t/parse-json-string-to-booleanquerybuilder/3803/2 "2011-01-18T18:28:21Z")

</div>

There is no option to parse a json query into its builder representation. Why do you want to do it? If you want to hack the query a bit (maybe add a filter, or something similar), then parse the json into a "Map of Maps", add what you need, and add the query as a map (automatically converted to a json) to the search request.  
On Tuesday, January 18, 2011 at 4:00 PM, srrIN wrote:

> Hi  
> I need to parse a Json query to booleanquerybuilder. But I am not sure how  
> to achieve this via Java api.  
> For e.g  
> { "bool" : { "must" : { "term" : { "author": "xyz" } } ,"must" : {  
> "has\_child" : {"type" : "person", "query" :{ "term" : { "name": "abc" } }} }  
> ,"must" : { "has\_child" : {"type" : "county", "query" :{ "term" : { "city":  
> "ny" } }} } } }
> 
> I need to parse the above json query to BooleanQueryBuilder. Can anyone help  
> me how to achieve this?  
> Thanks in advance.
> 
> --  
> View this message in context: [http://elasticsearch-users.115913.n3.nabble.com/Parse-JSON-string-to-BooleanQueryBuilder-tp2279996p2279996.html](http://elasticsearch-users.115913.n3.nabble.com/Parse-JSON-string-to-BooleanQueryBuilder-tp2279996p2279996.html)  
> Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![srrin](https://avatars.discourse-cdn.com/v4/letter/s/85f322/32.png) [@srrin](https://discuss.elastic.co/u/srrin)\
**Post date:** [January 19, 2011, 3:53am UTC](https://discuss.elastic.co/t/parse-json-string-to-booleanquerybuilder/3803/3 "2011-01-19T03:53:11Z")

</div>

Thank you Shay. Will try to Parse as MAP of MAPS.

---

<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, 4:13am UTC](https://discuss.elastic.co/t/parse-json-string-to-booleanquerybuilder/3803/4 "2017-07-06T04:13:34Z")

</div>


