NestedQuery document (Data API 18.2)

Nested query allows to query upon nested documents that are part of a larger document. The classical example is a product master with variants (in one big document) where you want to constraint a search to masters that have variants that match multiple constraints (like color = blue AND size = M).

Example: finds all the documents that has firstname = "John" and lastname = "Doe"
 { "query": { "bool_query": {
    "must": [ { "nested_query": { "path": "order.shipping_addresses", "query":
    { "bool_query": { "must": [ { "bool_query": { "must": [ { "term_query": {
    "fields": [ "order.shipping_addresses.first_name" ], "operator": "is",
    "values": [ "John" ] } } ] } }, { "bool_query": { "must": [ {
    "term_query": { "fields": [ "order.shipping_addresses.last_name" ],
    "operator": "is", "values": [ "Doe" ] } } ] } } ] } }, "score_mode": "avg"
    } } ] } } } 
Property Type Constraints Description
path String mandatory=true, nullable=false  
query Query {BoolQuery, FilteredQuery, MatchAllQuery, NestedQuery, TermQuery, TextQuery} mandatory=true, nullable=false  
score_mode Enum {avg, total, max, none}