# Getting items with Qty equal to 0

**URL:** <https://discuss.elastic.co/t/getting-items-with-qty-equal-to-0/252657>\
**Category:** Elasticsearch\
**Created:** [October 20, 2020, 9:55am UTC](https://discuss.elastic.co/t/getting-items-with-qty-equal-to-0/252657 "2020-10-20T09:55:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Padam\_Sethia](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/padam_sethia/32/77507_2.png) [@Padam\_Sethia](https://discuss.elastic.co/u/Padam_Sethia)\
**Post date:** [October 20, 2020, 9:55am UTC](https://discuss.elastic.co/t/getting-items-with-qty-equal-to-0/252657/1 "2020-10-20T09:55:52Z")

</div>

Hello , I am quite a beginner in elasticsearch . I really can't figure out how to get back items with qty as 0 , the problem is my index document is structured like this :

` {` `	"children": [],` `	"created": "2020-10-15T16:56:33",` `	"updated": null,` `	"title": "Bagru aFabric",` `	"description": "",` `	"sku": "1",` `	"qty": 0.0,` `	"product_category": "run",` `	"fabric_combination": "060",` `	"print_technique": "bgr",` `	"design_number": "2555"` `}`

And the next docuement is

`{` `	"children": ` `	[` ` {` ` "size": "m",` ` "qty": "20.0"` ` },` ` {` ` "size": "l",` ` "qty": "0.0"` ` },` ` {` ` "size": "xl",` ` "qty": "0.0"` ` },` ` {` ` "size": "xxl",` ` "qty": "20.0"` ` },` ` {` ` "size": "xxxl",` ` "qty": "20.0"` ` }` `	],` `	"created": "2020-10-18T15:43:04",` `	"updated": null,` `	"title": "Yellow Jacket",` `	"description": "",` `	"sku": "2",` `	"qty": 20.0,` `	"product_category": "jkt",` `	"fabric_combination": "060",` `	"print_technique": "bgr",` `	"design_number": "2555"` `}`

Now I want items where either the one of the children has qty 0 or the main root qty is 0.

Currently my Elasticsearch query looks like this :

`body = {'query':` ` {` ` 'bool': {` ` 'must': {` ` 'multi_match': {` ` 'query': query, 'fields': ['*']}` ` },` ` 'filter': {` ` 'term': {'qty': 0}},` ` }` ` }` `}`

This only check for qty values at the root level , not the nested children. Also note I have not declared the children as a nested type , I just added it as an array .

Thanks a lot , any help would be much appreciated !

---

<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:** [November 17, 2020, 9:56am UTC](https://discuss.elastic.co/t/getting-items-with-qty-equal-to-0/252657/2 "2020-11-17T09:56:05Z")

</div>

Closed on November 17, 2020, 9:56am UTC

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