112 lines
3.3 KiB
Python
112 lines
3.3 KiB
Python
from goojia_utils import ElasticSearchClient
|
|
|
|
elastic_client = ElasticSearchClient(host='192.168.0.89')
|
|
|
|
def find_around_by_location_for_bus(city, location, small_type, distance=1000):
|
|
"""
|
|
查找周边poi
|
|
:param city:
|
|
:param location:
|
|
:param distance:
|
|
:return:
|
|
"""
|
|
|
|
try:
|
|
ret = elastic_client.scan_to_data_frame('gaode_map_poi', {
|
|
"_source": ["name"],
|
|
"query": {
|
|
"bool": {
|
|
"must_not": [
|
|
{
|
|
"term": {
|
|
"main_type": {
|
|
"value": 0 # 表示清洗后的数据
|
|
}
|
|
}
|
|
}
|
|
],
|
|
"filter": [
|
|
{"terms": {
|
|
"small_type": small_type
|
|
}},
|
|
{
|
|
"term": {
|
|
"city": {
|
|
"value": city
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"geo_distance": {
|
|
"distance": distance,
|
|
"location": location
|
|
}
|
|
}
|
|
]
|
|
}
|
|
}
|
|
});
|
|
if len(ret) > 0:
|
|
return ret['name'].tolist()
|
|
return []
|
|
except Exception as e:
|
|
print(e)
|
|
return []
|
|
|
|
def find_around_by_location(city, location, small_type, distance=1000):
|
|
"""
|
|
查找周边poi
|
|
:param city:
|
|
:param location:
|
|
:param distance:
|
|
:return:
|
|
"""
|
|
|
|
try:
|
|
ret = elastic_client.scan_to_data_frame('gaode_map_poi', {
|
|
"_source": ["name"],
|
|
"query": {
|
|
"bool": {
|
|
"must_not": [
|
|
{
|
|
"term": {
|
|
"status": {
|
|
"value": 1
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"term": {
|
|
"main_type": {
|
|
"value": 0 # 表示清洗后的数据
|
|
}
|
|
}
|
|
}
|
|
],
|
|
"filter": [
|
|
{"terms": {
|
|
"small_type": small_type
|
|
}},
|
|
{
|
|
"term": {
|
|
"city": {
|
|
"value": city
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"geo_distance": {
|
|
"distance": distance,
|
|
"location": location
|
|
}
|
|
}
|
|
]
|
|
}
|
|
}
|
|
});
|
|
if len(ret) > 0:
|
|
return ret['name'].tolist()
|
|
return []
|
|
except Exception as e:
|
|
print(e)
|
|
return [] |