title: Filter nested objects in elasticsearch query based on query
body: <p>I have doc with multiple nested documents. The nested queries work fine but they would still return all the nested objects (i.e. the whole document) even though search query would only match a few nested objects. It does however filter the documents as a whole.</p>
  
  <p>Here is an example:</p>
  
  <pre><code>PUT /demo
  {
    "mappings": {
      "company": {
        "properties": {
          "employees": {
            "type": "nested"
          }
        }
      }
    }
  }
  
  PUT
  /demo/company/1
  {
    "id": 1,
    "name": "Google",
    "emp_count": 3,
    "employees": [{
      "id": 1,
      "name": "John",
      "address": {
        "city": "Mountain View",
        "state": "California",
        "country": "United States"
      }
    }]
  }
  
  PUT
  /demo/company/2
  {
    "id": 1,
    "name": "Facebook",
    "emp_count": 3,
    "employees": [{
      "id": 1,
      "name": "Amber",
      "address": {
        "city": "Bangalore",
        "state": "Karnataka",
        "country": "India"
      }
    }, {
      "id": 1,
      "name": "Adrian",
      "address": {
        "city": "Palo Alto",
        "state": "California",
        "country": "United States"
      }
    }]
  }
  
  PUT
  /demo/company/3
  {
    "id": 1,
    "name": "Microsoft",
    "emp_count": 3,
    "employees": [{
      "id": 1,
      "name": "Aman",
      "address": {
        "city": "New York",
        "state": "New York",
        "country": "United States"
      }
    }]
  }
  </code></pre>
  
  <p>When searching for <code>India</code> in the address, I should ideally only get <code>Facebook</code> with one nested object, but I get all the nested objects. How can I filter the nested objects returned?</p>
  
  <p>Example query: </p>
  
  <pre><code>{
    "query": {
      "function_score":{
        "query":{
          "nested":{
           "path":"employees",
           "score_mode":"max",
           "query": {
              "multi_match":{
                "query":"India",
                "type":"cross_fields",
                "fields":[
                  "employees.address.city",
                  "employees.address.country",
                  "employees.address.state"
                ]
              }
            }
          }
        }
      }
    }
  }
  </code></pre>
  
  <p>Output of this query is <code>Facebook</code> with all employees while I only want  <code>Amber</code>.</p>