NestedQuery document (Data API 19.10)

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}    
X Privacy Update: We use cookies to make interactions with our websites and services easy and meaningful, to better understand how they are used and to tailor advertising. By continuing to use this site you are giving us your consent to do this.