I need to "transform" mysql query to Elasticsearch query. What is blocking me is "where" statement. Basically what I need is to find all items that are within distance of 25 miles based on latitude and longitude and where pickup is enabled OR where items do have delivery enabled and provided zip code
where
(
(
`enabled_pickup` = '1'
and(
ST_Distance_Sphere(
POINT(- 122.41941550000001 , 37.7749295) ,
geolocation
) / 1000 * 0.62137119223733
) <= 25
)
or(
`enabled_delivery` = '1'
`zip_code` = '94116'
)
)
and this is Elasticsearch query that is not working as expected
{
"query": {
"bool": {
"must": [
{
"bool": {
"should": [
{
"bool": {
"must": [
{
"match": {
"enabled_pickup": "1"
}
},
{
"geo_distance": {
"distance": "25 mi",
"geo_location": {
"lat": "37.7749295",
"lon": "-122.41941550000001"
}
}
}
]
}
},
{
"bool": {
"must": [
{
"term": {
"dispensary.delivery": "1"
}
},
{
"term": {
"zip_code": "94116"
}
}
]
}
}
]
}
}
]
}
} }
can somebody please point me in right direction?