Match Queries & Geo Distance


(Callum Hopkins) #1

Does anyone know how to add a GeoDistance fallback for a bool should query? I can filter results by location: (placeholder variables used)

{
    "query": {
        "bool": {
            "should": [
                {
                    "match": {
                        "field_a": "query_a"
                    }
                },
                {
                    "match": {
                       "field_b": "query_b"
                    }
                }
            ],
            "must_not": [
                {
                    "match": {
                        "_id": "123456"
                    }
                }
            ]
        },
        "filter": {
            "geo_distance": {
                "distance": "1km",
                "location": "01.1234567,-01.1234567"
            }
        }
    }

}

This works fine, but what would a query look like that if there was no results for the match queries in the should bool, it elasticsearch would get all results within the geo distance?


(system) #2