Commit 400d8613 authored by lixiaofang's avatar lixiaofang

add

parent 882e326c
...@@ -598,6 +598,8 @@ class TopicUtils(object): ...@@ -598,6 +598,8 @@ class TopicUtils(object):
return f return f
for k, v in filters.items(): for k, v in filters.items():
logging.info("get fffffffff:%s" % k)
logging.info("get fffffffff:%s" % v)
if not v: if not v:
continue continue
...@@ -633,10 +635,16 @@ class TopicUtils(object): ...@@ -633,10 +635,16 @@ class TopicUtils(object):
}) })
else: else:
if isinstance(v, list): if isinstance(v, list):
logging.info("get hhhhhhhhhh:%s"%k)
logging.info("get hhhhhhhhhh:%s"%v)
f.append({ f.append({
"terms": {k: v}, "terms": {k: v},
}) })
else: else:
logging.info("get hhhhfffffffhhhhhh:%s"%k)
logging.info("get hhhhhhfffhhhh:%s"%v)
f.append({ f.append({
"term": {k: v}, "term": {k: v},
}) })
...@@ -805,51 +813,3 @@ class TopicUtils(object): ...@@ -805,51 +813,3 @@ class TopicUtils(object):
"total_count": 0 "total_count": 0
} }
@classmethod
def business_topic_id(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"]
match = {
"match": {
"content": {
query
}
}
}
q = {
"query": {
"bool": {
"must": must,
"must_not": cls.process_nfilters(nfilters),
}
}
}
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
}
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