title: What is wrong with my elasticsearch query ? Getting a expected end object error
body: <p>I'm trying to do a elasticsearch query that does geolocation filter and does some matching on nested documents, but I'm getting this error whenever I add in the nested query.</p>
  
  <blockquote>
    <p>"[bool] malformed query, expected [END_OBJECT] but found [FIELD_NAME]"</p>
  </blockquote>
  
  <pre><code>{
    "sort": [
      {
        "_score": {
          "order": "desc"
        }
      }
    ],
    "query": {
      "bool": {
        "filter": {
          "geo_distance": {
            "distance": "10km",
            "geolocation": [
              -73.980090948125,
              40.747844918436
            ]
          }
        },
        "must": {
          "multi_match": {
            "query": "New York",
            "fields": [
              "name^2",
              "city",
              "state",
              "zip"
            ],
            "type": "best_fields"
          }
        }
      },
      "nested": {
        "path": "amenities",
        "query": {
          "bool": {
            "must": [
              {
                "match": {
                  "amenities.name": "Pool"
                }
              }
            ]
          }
        }
      }
    },
    "aggs": {
      "reviews": {
        "nested": {
          "path": "reviews"
        },
        "aggs": {
          "avg_rating": {
            "avg": {
              "field": "reviews.rating"
            }
          }
        }
      }
    }
  }
  </code></pre>