优化全量统计

This commit is contained in:
沈健
2025-04-08 17:51:45 +08:00
parent c936b2c2c5
commit d183ca5c6c
@@ -34,19 +34,29 @@ def calculate_confidence(row):
def stat(city): def stat(city):
community_summary_df = es206_client.scan_to_data_frame(query={"query": { if pd.notna(city):
"bool": { query = {
"must": [ "bool": {
{ "must": [
"term": { {
"city": { "terms": {
"value": city "city": [city]
} }
} }
} ]
] }
} }
}}, source=[ else:
query = {
"bool": {
"must": [
{
"match_all": {}
}
]
}
}
community_summary_df = es206_client.scan_to_data_frame(query={"query": query}, source=[
"city", "city",
"region", "region",
"consumption_rating", "consumption_rating",
@@ -110,19 +120,29 @@ def detail(city):
""" """
计算消费潜力 计算消费潜力
""" """
community_summary_df = es206_client.scan_to_data_frame(query={"query": { if pd.notna(city):
query = {
"bool": { "bool": {
"must": [ "must": [
{ {
"term": { "terms": {
"city": { "city": [city]
"value": city }
} }
} ]
}
]
} }
}}, source=[ }
else:
query = {
"bool": {
"must": [
{
"match_all": {}
}
]
}
}
community_summary_df = es206_client.scan_to_data_frame(query={"query": query}, source=[
"id", "id",
"city", "city",
"region", "region",