From 6aa577f429778ef9b85b60eebcf4d3eb8fe34991 Mon Sep 17 00:00:00 2001 From: "wangwenyan@fangjia.com" Date: Wed, 5 Dec 2018 13:59:20 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=BD=97=E5=B9=B2=E5=9D=87?= =?UTF-8?q?=E4=BB=B7=E7=AE=97=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PriceSystem/fangjia/__init__.py | 41 ++++++++++++++++++++-- PriceSystem/rent_price/district_map0413.py | 2 +- 2 files changed, 39 insertions(+), 4 deletions(-) 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) #提取周边小区数据