# JsonGenerationException for Boosting query

**URL:** <https://discuss.elastic.co/t/jsongenerationexception-for-boosting-query/22738>\
**Category:** Elasticsearch\
**Created:** [March 18, 2015, 2:51pm UTC](https://discuss.elastic.co/t/jsongenerationexception-for-boosting-query/22738 "2015-03-18T14:51:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![nidhi\_chawhan](https://avatars.discourse-cdn.com/v4/letter/n/d78d45/32.png) [@nidhi\_chawhan](https://discuss.elastic.co/u/nidhi_chawhan)\
**Post date:** [March 18, 2015, 2:51pm UTC](https://discuss.elastic.co/t/jsongenerationexception-for-boosting-query/22738/1 "2015-03-18T14:51:39Z")

</div>

Hi Team,  
I am using jest client to execute the execute the query.

Here is the ES query

GET visit.hippo\_en/visit:PlaceDocument/\_search  
{  
"query": {  
"bool": {  
"should": [  
{  
"match": {  
"title.value": {  
"query": "automium bar",  
"fuzziness":"AUTO",  
"prefix\_length":3,  
"analyzer":"visit\_hippo\_analyser",  
"boost": 5  
}  
}  
},  
{  
"match": {  
"\_all": {  
"query": "automium bar",  
"fuzziness":"AUTO",  
"prefix\_length":3,  
"analyzer":"visit\_hippo\_analyser"  
}  
}  
}  
],  
"minimum\_should\_match": 1  
}  
}  
}

Below is my json builder

XContentBuilder contentBuilder = XContentFactory.jsonBuilder()  
.startObject()  
.startObject("query")  
.startObject("bool").field("minimum\_should\_match",1)  
.startObject("should").field(  
XContentFactory.jsonBuilder().startObject("match")  
.startObject("title.value")  
.field("query", text)  
.field("fuzziness","AUTO")  
.field("prefix\_length", 3)  
.field("analyzer","visit\_hippo\_analyser")  
.field("boost",5)  
.endObject()  
.endObject().toString()).field(  
XContentFactory.jsonBuilder().startObject("match")  
.startObject("\_all")  
.field("query", text)  
.field("fuzziness","AUTO")  
.field("prefix\_length", 3)  
.field("analyzer","visit\_hippo\_analyser")  
.endObject()  
.endObject().toString())  
.startObject()  
.endObject()  
.endObject()  
.endObject();

Search search = new Search.Builder(contentBuilder.string())  
.addIndex(visitHippoIndexName+"\_"+lang).addType("visit:PlaceDocument")  
.build();  
try  
{  
io.searchbox.core.SearchResult result = jestClient.execute(search);  
if (result.isSucceeded())  
{  
List\<io.searchbox.core.SearchResult.Hit\<SearchResultJson, Void\>\> hits =  
result.getHits(SearchResultJson.class);  
for (io.searchbox.core.SearchResult.Hit\<SearchResultJson, Void\> hit : hits)  
{  
results.add(SearchResult.fromSearchResultJson(hit.source));  
System.out.println(hit.source.getTitle().getSource());  
}  
}  
} catch (Exception e)  
{  
logger.error("Exception occurred for while executing Search query",  
e.getMessage());  
throw new Exception("System problem with do searching based on text");  
}  
return results;

But i am getting the exception  
org.elasticsearch.common.jackson.JsonGenerationException: Can not write a  
field name, expecting a value

\*i am not to find the how to write having "should" syntax in java \*

Please help me to provide the to build the JSON so that i can fire it  
through jest client.Response will be appreciated!!!

Thanks

Nidhi

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/3ba6a71e-70c1-4b02-b479-17a6617a60dd%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/3ba6a71e-70c1-4b02-b479-17a6617a60dd%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 12:25am UTC](https://discuss.elastic.co/t/jsongenerationexception-for-boosting-query/22738/2 "2017-07-06T00:25:55Z")

</div>

Closed on July 6, 2017, 12:25am UTC


