Commit dd446861 authored by lixiaofang's avatar lixiaofang

add

parent ed24f39e
...@@ -956,3 +956,43 @@ class TopicUtils(object): ...@@ -956,3 +956,43 @@ class TopicUtils(object):
"hits": [], "hits": [],
"total_count": 0 "total_count": 0
} }
@classmethod
def business_filters(cls, filters, filter_online=True):
"""处理过滤器部分。"""
logging.info("get filters:%s" % filters)
f = [
{"term": {"is_deleted": False}},
]
if not filters:
return f
if filter_online:
f.append({"term": {"is_online": True}})
for k, v in filters.items():
if v in (None, '', []):
continue
if k == "content":
f.append({
"match": {k: v}
})
elif k == "virtual_content_level":
f.append({
"match": {k: v}
})
else:
f.append({
"term": {k: v},
})
return f
...@@ -19,7 +19,7 @@ def business_topic_search(filters, nfilters=None, sorts_by=None, offset=0, size= ...@@ -19,7 +19,7 @@ def business_topic_search(filters, nfilters=None, sorts_by=None, offset=0, size=
try: try:
result_list = TopicUtils.business_topic_ids( result_list = TopicUtils.business_filters(
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