Commit 7ad7afbb authored by 杨林's avatar 杨林

增加类目判断

parent 11c25c4d
......@@ -11,6 +11,7 @@ class ESTools:
_host = [{"host": '172.18.45.18', "port": 9200}, {"host": '172.18.45.17', "port": 9200},
{"host": '172.18.45.16', "port": 9200}, {"host": '172.18.69.190', "port": 9200},
{"host": '172.18.69.192', "port": 9200}]
# _host = 'localhost:9200'
_TB_RATE = 0.7
_JD_RATE = 0.55
......@@ -18,9 +19,10 @@ class ESTools:
def __init__(self):
self.es = Elasticsearch(self._host)
def search_tools(self, price=0, title="", size=20):
def search_tools(self, price=0, title="", category="", size=20):
"""
搜索es方法
:param category: 商品类目
:param price: 券后价
:param title: 商品名称
:param size: 商品数量
......@@ -58,21 +60,27 @@ class ESTools:
else:
return None
def data_format(self, price=0, title="", size=20):
def data_format(self, price=0, title="", category="", size=20):
"""
格式化数据方法
:param category: 商品类目
:param price: 券后价
:param title: 商品标题
:param size: 商品数量
:return: 格式化后的数据
"""
res, sco = self.search_tools(price=price, title=title, size=size)
res, sco = self.search_tools(price=price, title=title, category=category, size=size)
if res:
temp = []
# 匹配分数平均数
score_avg = sum(sco) / len(sco)
# 匹配分数中位数
score_median = sco[int(len(sco) / 2)]
score_max = max(sco)
if score_max < 50:
return None
else:
for i in res:
# 对每条数据进行处理
# 分数大于中位数
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment