Commit 3b60331b authored by lixiaofang's avatar lixiaofang

add

parent b945e2f5
...@@ -155,9 +155,9 @@ class ESPerform(object): ...@@ -155,9 +155,9 @@ class ESPerform(object):
bulk_actions = [] bulk_actions = []
if sub_index_name == "topic" or \ if sub_index_name=="topic" or \
sub_index_name == "topic-star-routing" or \ sub_index_name=="topic-star-routing" or \
sub_index_name == "topic-high-star": sub_index_name=="topic-high-star":
for data in data_list: for data in data_list:
if data: if data:
bulk_actions.append({ bulk_actions.append({
...@@ -232,7 +232,7 @@ class ESPerform(object): ...@@ -232,7 +232,7 @@ class ESPerform(object):
return {"total_count": 0, "hits": []} return {"total_count": 0, "hits": []}
@classmethod @classmethod
def get_analyze_results(cls, es_cli, sub_index_name, query_body): def get_analyze_results(cls,es_cli, sub_index_name, query_body):
try: try:
assert (es_cli is not None) assert (es_cli is not None)
...@@ -242,7 +242,7 @@ class ESPerform(object): ...@@ -242,7 +242,7 @@ class ESPerform(object):
logging.error("index:%s is not existing,get_search_results error!" % official_index_name) logging.error("index:%s is not existing,get_search_results error!" % official_index_name)
return None return None
res = es_cli.indices.analyze(index=official_index_name, body=query_body) res = es_cli.indices.analyze(index=official_index_name,body=query_body)
return res return res
except: except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc()) logging.error("catch exception,err_msg:%s" % traceback.format_exc())
...@@ -276,7 +276,7 @@ class ESPerform(object): ...@@ -276,7 +276,7 @@ class ESPerform(object):
if high_num > 3: if high_num > 3:
logging.info("check es_nodes_load high,cpu load:%s,ori_cpu_info:%s" % ( logging.info("check es_nodes_load high,cpu load:%s,ori_cpu_info:%s" % (
str(es_nodes_list), str(es_nodes_info_list))) str(es_nodes_list), str(es_nodes_info_list)))
return True return True
else: else:
return False return False
...@@ -298,8 +298,8 @@ class ESPerform(object): ...@@ -298,8 +298,8 @@ class ESPerform(object):
functions_list += [ functions_list += [
{ {
"filter": { "filter": {
"constant_score": { "constant_score":{
"filter": { "filter":{
"term": {"content_level": 6}} "term": {"content_level": 6}}
} }
}, },
...@@ -307,8 +307,8 @@ class ESPerform(object): ...@@ -307,8 +307,8 @@ class ESPerform(object):
}, },
{ {
"filter": { "filter": {
"constant_score": { "constant_score":{
"filter": { "filter":{
"term": {"content_level": 5}} "term": {"content_level": 5}}
} }
}, },
...@@ -316,8 +316,8 @@ class ESPerform(object): ...@@ -316,8 +316,8 @@ class ESPerform(object):
}, },
{ {
"filter": { "filter": {
"constant_score": { "constant_score":{
"filter": { "filter":{
"term": {"content_level": 4}} "term": {"content_level": 4}}
} }
}, },
...@@ -411,7 +411,7 @@ class ESPerform(object): ...@@ -411,7 +411,7 @@ class ESPerform(object):
} }
}, },
"_source": { "_source": {
"include": ["id", "user_id"] "include": ["id","user_id"]
}, },
"sort": [ "sort": [
{"_score": {"order": "desc"}}, {"_score": {"order": "desc"}},
...@@ -420,7 +420,7 @@ class ESPerform(object): ...@@ -420,7 +420,7 @@ class ESPerform(object):
], ],
"collapse": { "collapse": {
"field": "user_id" "field": "user_id"
} }
} }
if len(have_read_topic_id_list) > 0: if len(have_read_topic_id_list) > 0:
...@@ -429,8 +429,7 @@ class ESPerform(object): ...@@ -429,8 +429,7 @@ class ESPerform(object):
"id": have_read_topic_id_list "id": have_read_topic_id_list
} }
} }
result_dict = ESPerform.get_search_results(ESPerform.get_cli(), sub_index_name="topic-high-star", result_dict = ESPerform.get_search_results(ESPerform.get_cli(), sub_index_name="topic-high-star", query_body=q,
query_body=q,
offset=0, size=size, routing="6") offset=0, size=size, routing="6")
topic_id_list = [item["_source"]["id"] for item in result_dict["hits"]] topic_id_list = [item["_source"]["id"] for item in result_dict["hits"]]
...@@ -442,7 +441,7 @@ class ESPerform(object): ...@@ -442,7 +441,7 @@ class ESPerform(object):
logging.info("topic_id_list:%s" % str(topic_id_dict)) logging.info("topic_id_list:%s" % str(topic_id_dict))
return topic_id_list, topic_id_dict return topic_id_list,topic_id_dict
except: except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc()) logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return list() return list()
{"dynamic":"strict", {
"dynamic":"strict",
"_routing": {"required": true}, "_routing": {"required": true},
"properties": { "properties": {
"id":{"type":"long"}, "id":{"type":"long"},
......
...@@ -8,18 +8,18 @@ ...@@ -8,18 +8,18 @@
"vote_num":{"type":"long"}, "vote_num":{"type":"long"},
"total_vote_num":{"type":"long"}, "total_vote_num":{"type":"long"},
"reply_num":{"type":"long"}, "reply_num":{"type":"long"},
"name":{"type":"text","analyzer":"keyword","search_analyzer":"keyword"}, "name":{"type":"text","analyzer":"gm_default_index","search_analyzer":"gm_default_index"},
"description":{"type":"text","analyzer":"keyword","search_analyzer":"keyword"}, "description":{"type":"text","analyzer":"gm_default_index","search_analyzer":"gm_default_index"},
"content":{"type":"text","analyzer":"keyword","search_analyzer":"keyword"}, "content":{"type":"text","analyzer":"gm_default_index","search_analyzer":"gm_default_index"},
"content_level":{"type":"text"}, "content_level":{"type":"text"},
"user_id":{"type":"long"}, "user_id":{"type":"long"},
"user_nick_name":{"type":"text","analyzer":"keyword","search_analyzer":"keyword"},//帖子用户名 "user_nick_name":{"type":"text","analyzer":"gm_default_index","search_analyzer":"gm_default_index"},//帖子用户名
"user_nick_name_pre": {"type":"text","analyzer":"keyword"}, //不切词的用户名 "user_nick_name_pre": {"type":"text","analyzer":"keyword"}, //不切词的用户名
"group_id":{"type":"long"}, //所在组ID "group_id":{"type":"long"}, //所在组ID
"tag_list":{"type":"long"},//标签属性 "tag_list":{"type":"long"},//标签属性
"useful_tag_list":{"type":"long"},//有用标签属性 "useful_tag_list":{"type":"long"},//有用标签属性
"edit_tag_list":{"type":"long"},//编辑标签 "edit_tag_list":{"type":"long"},//编辑标签
"tag_name_list":{"type":"text","analyzer":"keyword","search_analyzer":"keyword"}, "tag_name_list":{"type":"text","analyzer":"gm_default_index","search_analyzer":"gm_default_index"},
"share_num":{"type":"long"}, "share_num":{"type":"long"},
"pick_id_list":{"type":"long"}, "pick_id_list":{"type":"long"},
"offline_score":{"type":"double"},//离线算分 "offline_score":{"type":"double"},//离线算分
...@@ -44,14 +44,14 @@ ...@@ -44,14 +44,14 @@
"platform": {"type": "long"}, "platform": {"type": "long"},
"platform_id": {"type": "long"}, "platform_id": {"type": "long"},
"drop_score":{"type": "long"}, // 人工降分 "drop_score":{"type": "double"}, // 人工降分
"sort_score":{"type": "double"}, // 排序分 "sort_score":{"type": "double"}, // 排序分
"pictorial_id":{"type": "long"}, //所在组ID "pictorial_id":{"type": "long"}, //所在组ID
"pictorial_name":{ // 所在组名称 "pictorial_name":{ // 所在组名称
"type": "text", "type": "text",
"analyzer": "keyword", "analyzer": "gm_default_index",
"search_analyzer": "keyword" "search_analyzer": "gm_default_index"
}, },
"is_excellent":{"type": "long"}, "is_excellent":{"type": "long"},
"is_operation_home_recommend": {"type": "boolean"}, //是否首页运营推荐 "is_operation_home_recommend": {"type": "boolean"}, //是否首页运营推荐
......
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
"platform": {"type": "long"}, "platform": {"type": "long"},
"platform_id": {"type": "long"}, "platform_id": {"type": "long"},
"drop_score":{"type": "long"}, // 人工降分 "drop_score":{"type": "double"}, // 人工降分
"sort_score":{"type": "double"}, // 排序分 "sort_score":{"type": "double"}, // 排序分
"pictorial_id":{"type": "long"}, //所在组ID "pictorial_id":{"type": "long"}, //所在组ID
......
...@@ -8,18 +8,18 @@ ...@@ -8,18 +8,18 @@
"vote_num":{"type":"long"}, "vote_num":{"type":"long"},
"total_vote_num":{"type":"long"}, "total_vote_num":{"type":"long"},
"reply_num":{"type":"long"}, "reply_num":{"type":"long"},
"name":{"type":"text","analyzer":"keyword","search_analyzer":"keyword"}, "name":{"type":"text","analyzer":"gm_default_index","search_analyzer":"gm_default_index"},
"description":{"type":"text","analyzer":"keyword","search_analyzer":"keyword"}, "description":{"type":"text","analyzer":"gm_default_index","search_analyzer":"gm_default_index"},
"content":{"type":"text","analyzer":"keyword","search_analyzer":"keyword"}, "content":{"type":"text","analyzer":"gm_default_index","search_analyzer":"gm_default_index"},
"content_level":{"type":"text"}, "content_level":{"type":"text"},
"user_id":{"type":"long"}, "user_id":{"type":"long"},
"user_nick_name":{"type":"text","analyzer":"keyword","search_analyzer":"keyword"},//帖子用户名 "user_nick_name":{"type":"text","analyzer":"gm_default_index","search_analyzer":"gm_default_index"},//帖子用户名
"user_nick_name_pre": {"type":"text","analyzer":"keyword"}, //不切词的用户名 "user_nick_name_pre": {"type":"text","analyzer":"keyword"}, //不切词的用户名
"group_id":{"type":"long"}, //所在组ID "group_id":{"type":"long"}, //所在组ID
"tag_list":{"type":"long"},//标签属性 "tag_list":{"type":"long"},//标签属性
"useful_tag_list":{"type":"long"},//有用标签属性 "useful_tag_list":{"type":"long"},//有用标签属性
"edit_tag_list":{"type":"long"},//编辑标签 "edit_tag_list":{"type":"long"},//编辑标签
"tag_name_list":{"type":"text","analyzer":"keyword","search_analyzer":"keyword"}, "tag_name_list":{"type":"text","analyzer":"gm_default_index","search_analyzer":"gm_default_index"},
"share_num":{"type":"long"}, "share_num":{"type":"long"},
"pick_id_list":{"type":"long"}, "pick_id_list":{"type":"long"},
"offline_score":{"type":"double"},//离线算分 "offline_score":{"type":"double"},//离线算分
...@@ -44,14 +44,14 @@ ...@@ -44,14 +44,14 @@
"platform": {"type": "long"}, "platform": {"type": "long"},
"platform_id": {"type": "long"}, "platform_id": {"type": "long"},
"drop_score":{"type": "long"}, // 人工降分 "drop_score":{"type": "double"}, // 人工降分
"sort_score":{"type": "double"}, // 排序分 "sort_score":{"type": "double"}, // 排序分
"pictorial_id":{"type": "long"}, //所在组ID "pictorial_id":{"type": "long"}, //所在组ID
"pictorial_name":{ // 所在组名称 "pictorial_name":{ // 所在组名称
"type": "text", "type": "text",
"analyzer": "keyword", "analyzer": "gm_default_index",
"search_analyzer": "keyword" "search_analyzer": "gm_default_index"
}, },
"is_excellent":{"type": "long"}, "is_excellent":{"type": "long"},
"is_operation_home_recommend": {"type": "boolean"}, //是否首页运营推荐 "is_operation_home_recommend": {"type": "boolean"}, //是否首页运营推荐
......
...@@ -4,11 +4,9 @@ from __future__ import unicode_literals, absolute_import, print_function ...@@ -4,11 +4,9 @@ from __future__ import unicode_literals, absolute_import, print_function
import time import time
from django.conf import settings from django.conf import settings
from django.core.management.base import BaseCommand, CommandError from django.core.management.base import BaseCommand, CommandError
import traceback import traceback
import logging import logging
import datetime import datetime
import time
from libs.es import ESPerform from libs.es import ESPerform
from django.db import models from django.db import models
from alpha_types.venus import GRAP_PLATFORM from alpha_types.venus import GRAP_PLATFORM
...@@ -309,7 +307,6 @@ class Topic(models.Model): ...@@ -309,7 +307,6 @@ class Topic(models.Model):
return related_billboard_list return related_billboard_list
except: except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc()) logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return [] return []
......
...@@ -8,7 +8,6 @@ from libs.tools import tzlc ...@@ -8,7 +8,6 @@ from libs.tools import tzlc
import time import time
import re import re
import datetime import datetime
from trans2es.models.user import User from trans2es.models.user import User
from trans2es.models.topic import ExcellentTopic, TopicHomeRecommend from trans2es.models.topic import ExcellentTopic, TopicHomeRecommend
......
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