I want to get the document in which nested child contains both words Mifune AND Miller-Meteor.
For more detail of nested, I've gone through Nested query | Elasticsearch Guide [8.11] | Elastic
here are the mappings
{ "mappings" : { "properties" : { "driver" : { "type" : "nested", "properties" : { "last_name" : { "type" : "text" }, "vehicle" : { "type" : "nested", "properties" : { "make" : { "type" : "text" }, "model" : { "type" : "text" } } } } } } } }
i've two documents in the index
{ "driver" : { "last_name" : "McQueen", "vehicle" : [ { "make" : "Powell Motors", "model" : "Canyonero" }, { "make" : "Miller-Meteor", "model" : "Ecto-1" } ] } },{ "driver" : { "last_name" : "Hudson", "vehicle" : [ { "make" : "Mifune", "model" : "Mach Five" }, { "make" : "Miller-Meteor", "model" : "Ecto-1" } ] } }
hitting query
{ "query" : { "nested" : { "path" : "driver", "query" : { "nested" : { "path" : "driver.vehicle", "query" : { "bool" : { "must" : [ { "match" : { "driver.vehicle.make" : "Mifune" } }, { "match" : { "driver.vehicle.make" : "Miller-Meteor" } } ] } } } } } } }
I tried the above query but it did not work
also tried with query_string AND operator but it also not worked
{ "query": { "nested": { "path": "driver", "query": { "nested": { "path": "driver.vehicle", "query": { "bool": { "must": [ { "query_string": { "query": "Mifune AND Miller-Meteor", "fields": ["driver.vehicle.make"] } } ] } } } } } } }