I have data of the form
{
"Name": "Bolognaise, tomato, olive and feta tart"
"Prep Time": 20,
"Cook Time": 25,
"Servings": 4,
"Ingredients": [
{
"name": "puff pastry",
"id": 17,
"weight": 100
},
{ "name": "bolognaise",
"id": 18,
"weight": 150
},
{
"name": "tomatoes",
"id": 19,
"weight": 200
},
{
"name": "olives",
"id": 20,
"weight": 300
},
{
"name": "cheese",
"id": 21,
"weight": 230
},
{
"name": "baby rocket",
"id": 22,
"weight": 400
}
],
"Views": 0,
"Urls": "xcd.com",
"Tags": [
"Tomato",
"Lunch"
],
"Main_ingredient": {
"type": "Tomato",
"id": 101,
"weight": 500
}
}
},
And I am using this query
{
"query": {
"bool": {
"must": [
{ "match": { "Main_ingredient.type": "Tomato" }},
{"range":{"Main_ingredient.weight":{"lte":1000}}},
{
"nested": {
"path": "Ingredients",
"query": {
"bool": {
"must": [
{ "match": { "Ingredients.name": "cheese" }},
{ "range": { "Ingredients.weight":{"lte":400} }},
{ "match": { "Ingredients.name": "olives" }},
{ "range": { "Ingredients.weight":{"lte":400} }}
]
}}}}
]
}}}
I want to change the query so that If I pass the weight and the main ingredient ,then it should return me the ids with the same main ingredient and weight of the main ingredient less than the passed weight . Right now it returns null