Commit 8c26d279 authored by lixiaofang's avatar lixiaofang

highlight

parent 05a61dff
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.6 (physical1)" project-jdk-type="Python SDK" />
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.6 (LiXiaoFang)" project-jdk-type="Python SDK" />
<component name="PyCharmProfessionalAdvertiser">
<option name="shown" value="true" />
</component>
......
......@@ -2,7 +2,7 @@
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="jdk" jdkName="Python 3.6 (physical1)" jdkType="Python SDK" />
<orderEntry type="jdk" jdkName="Python 3.6 (LiXiaoFang)" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
<component name="TestRunnerService">
......
......@@ -446,3 +446,13 @@ class ESPerform(object):
except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return list()
@classmethod
def get_highlight(cls, fields=[]):
field_highlight = {
'fields': {k: {} for k in fields},
'pre_tags': ['<%s>' % 'ems'],
'post_tags': ['</%s>' % 'ems']
}
return field_highlight
......@@ -324,6 +324,15 @@ class TopicUtils(object):
}
}
]
result_dict = ESPerform.get_search_results(ESPerform.get_cli(), sub_index_name=index_type, query_body=q,
offset=offset, size=size, routing=routing)
topic_id_list = list()
for item in result_dict["hits"]:
topic_id_list.append(item["_source"]["id"])
else:
multi_match = {
'query': query,
......@@ -406,13 +415,14 @@ class TopicUtils(object):
}
]
result_dict = ESPerform.get_search_results(ESPerform.get_cli(), sub_index_name=index_type, query_body=q,
offset=offset, size=size, routing=routing)
result_dict = ESPerform.get_search_results(ESPerform.get_cli(), sub_index_name=index_type, query_body=q,
offset=offset, size=size, routing=routing)
topic_id_list = list()
topic_id_list = list()
for item in result_dict["hits"]:
topic_id_list.append({"id": item["_source"]["id"], "highlight": item["highlight"]})
for item in result_dict["hits"]:
topic_id_list.append(item["_source"]["id"])
return topic_id_list
except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
......
......@@ -183,7 +183,9 @@ def get_home_recommend_topic_ids(user_id, device_id, tag_id, offset, size, query
# topic_id_list.extend(recommend_topic_list[3:6])
# else:
# topic_id_list.extend(rank_topic_id_list)
have_read_topic_id_list.extend(rank_topic_id_list)
logging.info("get rank_topic_id_list:%s" % rank_topic_id_list)
logging.info("get item:%s" % item["id"] for item in rank_topic_id_list)
have_read_topic_id_list.extend(item["id"] for item in rank_topic_id_list)
if len(have_read_topic_id_list) > 30000:
cut_len = len(have_read_topic_id_list) - 30000
have_read_topic_id_list = have_read_topic_id_list[cut_len:]
......
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