Commit 526c95ba authored by lixiaofang's avatar lixiaofang

add

parent 49ce2d7e
......@@ -717,17 +717,6 @@ class TopicUtils(object):
if v in (None, '', []):
continue
if k == "content":
f.append({
"match": {k: v}
})
if k == "virtual_content_level":
f.append({
"term": {k: v}
})
if k in ["create_time_gte", "create_time_lte"]:
if k == "create_time_gte":
......@@ -987,13 +976,7 @@ class TopicUtils(object):
@classmethod
def business_topic_ids(cls, filters, nfilters, sorts_by, offset=0, size=10, index_name="topic", filter_online=True):
# filter = {}
# for k, v in filters:
# if k != 'content':
# filter[k] = v
must = cls.process_filters(filters, filter_online=filter_online)
must = cls.business_filters(filters, filter_online=filter_online)
q = {
"query": {
"bool": {
......@@ -1024,3 +1007,36 @@ class TopicUtils(object):
"hits": [],
"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}
})
else:
f.append({
"term": {k: v},
})
return f
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