Commit b36ceeff authored by lixiaofang's avatar lixiaofang

add

parent c962e7b0
...@@ -738,3 +738,52 @@ class TopicUtils(object): ...@@ -738,3 +738,52 @@ class TopicUtils(object):
"hits": [], "hits": [],
"total_count": 0 "total_count": 0
} }
@classmethod
def business_topic_ids(cls, filters, nfilters, sorts_by, offset=0, size=10, index_name="topic", filter_online=True):
must = cls.process_filters(filters, filter_online=filter_online)
query = ''
for k, v in filters.items():
if k == "content":
query = filters["content"]
q = {
"query": {
"bool": {
"must": must,
"must_not": cls.process_nfilters(nfilters),
},
"multi_match":{
"fields" : ["title", "content"],
"type": "cross_fields",
"operator":"or",
"query":query
}
}
}
if sorts_by:
sorts = cls.process_sort(sorts_by)
if sorts:
q["sort"] = sorts
try:
result_dict = ESPerform.get_search_results(
ESPerform.get_cli(), sub_index_name=index_name,
query_body=q, offset=offset, size=size
)
return {
"hits": result_dict["hits"],
"total_count": result_dict["total_count"]
}
except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return {
"hits": [],
"total_count": 0
}
...@@ -18,7 +18,8 @@ def business_topic_search(filters, nfilters=None, sorts_by=None, offset=0, size= ...@@ -18,7 +18,8 @@ def business_topic_search(filters, nfilters=None, sorts_by=None, offset=0, size=
"""帖子搜索。""" """帖子搜索。"""
try: try:
result_list = TopicUtils.list_topic_ids(
result_list = TopicUtils.business_topic_ids(
filters=filters, nfilters=nfilters, sorts_by=sorts_by, filters=filters, nfilters=nfilters, sorts_by=sorts_by,
offset=offset, size=size, filter_online=False, offset=offset, size=size, filter_online=False,
index_name="topic" index_name="topic"
......
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