# ES 5.4 parsing exception

**URL:** <https://discuss.elastic.co/t/es-5-4-parsing-exception/106716>\
**Category:** Elasticsearch\
**Created:** [November 7, 2017, 3:54pm UTC](https://discuss.elastic.co/t/es-5-4-parsing-exception/106716 "2017-11-07T15:54:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Misha\_Pobereshy](https://avatars.discourse-cdn.com/v4/letter/m/8797f3/32.png) [@Misha\_Pobereshy](https://discuss.elastic.co/u/Misha_Pobereshy)\
**Post date:** [November 7, 2017, 3:54pm UTC](https://discuss.elastic.co/t/es-5-4-parsing-exception/106716/1 "2017-11-07T15:54:19Z")

</div>

Hi everyone . It would be helpful if someone can help me with this

"index": "default",  
"type": "user",  
"from": 0,  
"size": 10,  
"body": {  
"sort": [  
{  
"lastPost.created": {  
"order": "desc"  
}  
},  
{  
"firstName": "desc"  
},  
{  
"lastName": "desc"  
}  
],  
"query": {  
"bool": {  
"must": [  
{  
"match": {  
"sector.\_id": "56085c40d5497167554c6391"  
}  
}  
]  
},  
"terms": {  
"userId": [  
"59d6603e068e463698eca7cf",  
"58b12ef9154fd29f69b6f651"  
]  
}  
}  
}

returns an error:  
[parsing\_exception] [bool] malformed query, expected [END\_OBJECT] but found [FIELD\_NAME], with { line=1 col=169 }

Without terms it works, but I need to see users with specific id-s

---

<div class="post-metadata">

**Author:** ![jimczi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jimczi/32/47985_2.png) [@jimczi](https://discuss.elastic.co/u/jimczi)\
**Post date:** [November 8, 2017, 11:29am UTC](https://discuss.elastic.co/t/es-5-4-parsing-exception/106716/2 "2017-11-08T11:29:43Z")

</div>

The `terms` query must be embedded in the `bool` query directly in order to indicate the type of match that this query should handle (is it an optional clause or a mandatory one). For instance if the `terms` query is mandatory you'll need to add an entry in the `must` or `filter` (if scores are not needed) section of the `bool` query.

---

<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:** [December 6, 2017, 11:30am UTC](https://discuss.elastic.co/t/es-5-4-parsing-exception/106716/3 "2017-12-06T11:30:03Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
