title: Can i filter subarray in Elasticsearch?
body: <p>I have orders and order products attached for each order as subarray in Elastic Search. When i'm aggregating Prices i need possibility to filter my order products in my documents of orders. </p>
  
  <p>Example of my document in Elastic:</p>
  
  <pre><code>{  
     "OrderID":4567488,
     "projectId":"4",
     "Project":"direkt",
     "legacy_id":null,
     "supporterId":null,
     "Origin":"FR",
     "orderProducts":[  
        {  
           "OrderProductID":"15694898",
           "OrderID":"4567488",
           "brandNo":"30",
           "Price":"26.95",
        },
        {  
           "OrderProductID":"15694898",
           "OrderID":"4567488",
           "brandNo":"15",
           "Price":"15.22",
        },
         {  
           "OrderProductID":"15694898",
           "OrderID":"4567488",
           "brandNo":"123",
           "Price":"24.55",
        },
     ]
  }
  </code></pre>
  
  <p>How im filter right now:</p>
  
  <pre><code> {  
        "index":"order_index",
        "from":0,
        "size":100,
        "body":{  
           "query":{  
              "filtered":{  
                 "filter":{  
                    "bool":{  
                       "must":[  
                          {  
                             "term":{  
                                "orderProducts.brandNo":"30"
                             }
                          }
                       ],
                    }
                 }
              }
           }
        }
     }
  </code></pre>
  
  <p>What i'm expecting</p>
  
  <pre><code>{  
     "OrderID":4567488,
     "projectId":"4",
     "Project":"direkt",
     "legacy_id":null,
     "supporterId":null,
     "Origin":"FR",
     "orderProducts":[  
        {  
           "OrderProductID":"15694898",
           "OrderID":"4567488",
           "brandNo":"30",
           "Price":"26.95",
        },
     ]
  }
  </code></pre>
  
  <p>What i'm really getting:</p>
  
  <p><em>All document.</em></p>
  
  <p>That is possible? To filter subarray data?</p>
  
  <p><strong>UPD.</strong></p>
  
  <p>Yes this is my schema mappings:</p>
  
  <pre><code>"mappings":{  
     "order":{  
        "dynamic_templates":[  
           {  
              "strings":{  
                 "mapping":{  
                    "type":"string",
                    "fields":{  
                       "raw":{  
                          "index":"not_analyzed",
                          "type":"string"
                       }
                    }
                 },
                 "match_mapping_type":"string"
              }
           }
        ],
        "properties":{  
           "orderProducts":{  
              "include_in_parent":true,
              "properties":{  
                 "OrderProductID":{  
                    "type":"long"
                 },
                 "OrderID":{  
                    "type":"long"
                 },
                 "brandNo":{  
                    "type":"long"
                 },
                 "Price":{  
                    "type":"double"
                 }
  
              },
              "type":"nested"
           },
           "OrderID":{  
              "type":"long"
           }
        }
     }
  },
  </code></pre>