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 !