diff --git a/PriceSystem/fangjia/__init__.py b/PriceSystem/fangjia/__init__.py index 22a9d32..46a0e43 100644 --- a/PriceSystem/fangjia/__init__.py +++ b/PriceSystem/fangjia/__init__.py @@ -13,10 +13,11 @@ from rediscluster import StrictRedisCluster from fangjia import mongoClients as mongoClients from fangjia import ElasticsearchClient as es from fangjia.cachedObjectWrapper import CachedObjectWrapper -# +from elasticsearch import Elasticsearch, helpers formatter = logging.Formatter('%(processName)s %(asctime)s %(name)-6s %(levelname)-6s %(message)s') - +client_DB_es = Elasticsearch('192.168.0.206', port=9200, timeout=1000, http_auth=('developer', '5e8edd851d2fdfbd7415232c67367cc3')) +ES_db_index = "seawater-2018,seawater-2017,seawater-2016" def get_logger(name): logger = logging.getLogger(name) @@ -540,7 +541,41 @@ def get_default_redis_connection(): return redis_connection - +def findHouse2(query): + # local_switch and select_content are not applied in this function + + # query = {"city": ct, "cat": "rent", "region": rl, # 'rent_type':'整租', + # "district_name": {"$in": lk}, + # "p_date": {"$gt": timd, "$lt": timm}} + city = query['city'] + region = query['region'] + # district_name = lk[0] + name_pack = findquery_statement['name_pack'] + query_list = list(helpers.scan( + index=ES_db_index, + client=client_DB_es, + scroll='20m', + size=1000, + doc_type="_doc", + query={ + # "_source": ["area"], + "query": + {"bool": + {"must": + [{"term": {"cat": "rent"}}, + {"term": {"city": city}}, + {"term": {"region": region}}, + # {"term": {"district_name": district_name}}, + {"terms": {"district_name": lk}}, + # {"terms": {"district_name": ["新泾三村", "新泾四村"]}}, + {"range": {"p_date": { + "gte": timd, "lte": timm}}} + ], "must_not": [], "should": [] + } + }, "from": 0, "size": 0, "sort": [], "aggs": {}} + )) + + return pd.DataFrame(query_list) diff --git a/PriceSystem/rent_price/district_map0413.py b/PriceSystem/rent_price/district_map0413.py index 65cb440..9851ed6 100644 --- a/PriceSystem/rent_price/district_map0413.py +++ b/PriceSystem/rent_price/district_map0413.py @@ -179,7 +179,7 @@ def common_rent_price(ct,rl,p,timd,timm,region_feature,mongodb): "district_name":{"$in":lk}, "p_date":{"$gt":timd,"$lt":timm}} - return fangjia.findHouse(query) + return fangjia.findHouse2(query) #提取周边小区数据