title: Elasticsearch: query produced is invalid
body: <p>I'm getting a little frustrated with elasticsearch, after having read the documents, but can't seem to get beyond a 'The query produced is invalid" response. What I am trying to do is use elasticsearch to find imperfect duplicates in geospatial information and a rather large dataset. I want to match on name (boosted) and address, filter results a small geographic box and then reduce the relevance score of matches that are located further from my reference point. Can someone please help? I think I understnad the individual elements of a query, my main problem is putting these together in a way that products something valid.</p>
  
  <pre><code>$query = new \Elastica\Query\Builder('{
          "function_score": {
              "functions": [
                  {
                      "gauss": {
                          "location": {
                              "origin": "'.$latitude.', '.$longitude.'",
                              "scale": "2km"
                          }
                      }
                  }
              ],
              "query": {
                  "filtered": {
                      "query": {
                          "bool": {
                              "should": [
                                  {
                                      "match": {
                                          "name": {
                                              "query": "'.$name.'",
                                              "boost": 4
                                          }
                                      }
                                  },
                                  {
                                      "match": {
                                          "address": {
                                              "query": "'.$address.'",
                                              "boost": 1
                                          }
                                      }
                                  }
                              ]
                          }
                      },
                      "filter": {
                          "geo_distance": {
                              "distance": "2km",
                              "location": {
                                  "lat": "'.$latitude.'",
                                  "lon": "'.$longitude.'"
                              }
                          }
                      }
                  }
  
              }
      }')
  </code></pre>