Parse JSON string to BooleanQueryBuilder


(srrin) #1

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.


(Shay Banon) #2

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
Sent from the ElasticSearch Users mailing list archive at Nabble.com.


(srrin) #3

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


(system) #4