Files
airflow/dags/poi/business/poiutils.py
T
2024-11-14 16:14:16 +08:00

54 lines
1.5 KiB
Python

from goojia_utils import ElasticSearchClient
elastic_client = ElasticSearchClient(host='192.168.0.206')
def find_around_by_location(city, location, typecode, distance=1000):
"""
查找周边poi
:param city:
:param location:
:param distance:
:return:
"""
try:
ret = elastic_client.scan_to_data_frame('amap_poi', {
"_source": ["name"],
"query": {
"bool": {
"must_not": [
{
"term": {
"status": {
"value": 1
}
}
}
],
"filter": [
{"terms": {
"typecode": typecode
}},
{
"term": {
"cityname": {
"value": city
}
}
},
{
"geo_distance": {
"distance": distance,
"location": location
}
}
]
}
}
});
if len(ret) > 0:
return ret['name'].tolist()
return []
except Exception as e:
print(e)
return []