我需要将 mysql 查询“转换”为 Elasticsearch 查询。阻止我的是“where”语句。基本上我需要的是根据纬度和经度找到 25 英里范围内的所有物品以及启用取件的位置或启用递送并提供邮政编码的物品
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'
)
)
这是未按预期工作的 Elasticsearch 查询
{
"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"
}
}
]
}
}
]
}
}
]
}
} }
有人可以指出我正确的方向吗?
我正在阅读类似的问题,您可以尝试使用以下查询。您可以通过此 stackoverflow 讨论找到正在解决的类似问题
希望这会有所帮助,干杯!
{
"query": {
"bool": {
"should": [
{
"bool": {
"must": [
{"match": { "enabled_pickup": "1"}}
,{ "match": {
"geo_distance": {
"distance": "25 mi",
"geo_location": {
"lat": "37.7749295",
"lon": "-122.41941550000001"
}
}
}
}
]
}
,
"bool": {
"must": [
{ "match": {"dispensary.delivery": "1"} }
,{"match": {"zip_code": "94116"} }
]
}
}
]
}
}
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句