diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..831951dbb5fb03b4ad668402d5d1b04953f315df --- /dev/null +++ b/.gitignore @@ -0,0 +1,71 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*~ +# C extensions +*.so + +# Distribution / packaging +.Python +.vscode +env/ +bin/ +build/ +develop-eggs/ +dist/ +eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +.idea/ +*.egg-info/ +.installed.cfg +*.egg + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.cache +nosetests.xml +coverage.xml + +# Translations +*.mo + +# Mr Developer +.mr.developer.cfg +.project +.pydevproject + +# Rope +.ropeproject + +# Django stuff: +*.log +*.pot + +# Sphinx documentation +docs/_build/ + + +# config +fabfile.py +settings.online.py +settings_local.py +media/ +log/ +crawldata/ +conf/ +/static +.vagrant/ +Vagrantfile + +*.DS_Store +dump.rdb diff --git a/search/utils/__pycache__/__init__.cpython-36.pyc b/search/utils/__pycache__/__init__.cpython-36.pyc deleted file mode 100644 index f6995f5e3b61a43bbb8db1a1711749c4a1228500..0000000000000000000000000000000000000000 Binary files a/search/utils/__pycache__/__init__.cpython-36.pyc and /dev/null differ diff --git a/search/utils/__pycache__/pick.cpython-36.pyc b/search/utils/__pycache__/pick.cpython-36.pyc deleted file mode 100644 index 0238c72e5a1853eb9e39689d11572380c443a727..0000000000000000000000000000000000000000 Binary files a/search/utils/__pycache__/pick.cpython-36.pyc and /dev/null differ diff --git a/search/utils/__pycache__/topic.cpython-36.pyc b/search/utils/__pycache__/topic.cpython-36.pyc deleted file mode 100644 index cd4db6014ffd75c9cb4570d84f04e1fbb33aed4e..0000000000000000000000000000000000000000 Binary files a/search/utils/__pycache__/topic.cpython-36.pyc and /dev/null differ diff --git a/search/utils/topic.py b/search/utils/topic.py index 31ce55465ce874d737efa3821ef47395b028c6a7..9a2085f326282b595ad173f20bb13dabc11c4954 100644 --- a/search/utils/topic.py +++ b/search/utils/topic.py @@ -4,6 +4,9 @@ import logging import traceback import json + +from alpha_types.venus import TOPIC_SEARCH_SORT + from libs.es import ESPerform from .common import TopicDocumentField from search.utils.common import * @@ -464,4 +467,80 @@ class TopicUtils(object): return result_dict["hits"] except: logging.error("catch exception,err_msg:%s" % traceback.format_exc()) - return list() \ No newline at end of file + return list() + + @classmethod + def process_filters(cls, filters): + """处ç†è¿‡æ»¤å™¨éƒ¨åˆ†ã€‚""" + + f = [ + {"term": {"is_online": True}}, + {"term": {"is_deleted": False}}, + ] + if not filters: + return f + + for k, v in filters.items(): + if k == "group_id": + f.append({ + "term": {"group_id": v}, + }) + + return f + + @classmethod + def process_nfilters(cls, nfilters): + """处ç†è¿‡æ»¤å™¨éƒ¨åˆ†ã€‚""" + + nf = [] + if not nfilters: + return nf + + for k, v in nfilters.items(): + pass + + return nf + + @classmethod + def process_sort(cls, sorts_by): + """å¤„ç†æŽ’åºéƒ¨åˆ†ã€‚""" + + sort_rule = [] + for sort in sorts_by: + if sort == TOPIC_SEARCH_SORT.VOTE_NUM: + sort_rule.append({ + "vote_num":{ + "order":"desc" + } + }) + + return sort_rule + + @classmethod + def list_topic_ids(cls, filters, nfilters, sorts_by, offset=0, size=10): + + q = { + "query": { + "bool": { + "must": cls.process_filters(filters), + "must_not": cls.process_nfilters(nfilters), + } + }, + "_source": { + "includes":["id"] + }, + "sort": [], + } + + if sorts_by: + sorts = cls.process_sort(sorts_by) + q["sort"] = sorts + + try: + result_dict = ESPerform.get_search_results(ESPerform.get_cli(), sub_index_name="topic", + query_body=q, offset=offset, size=size) + + return result_dict["hits"] + except: + logging.error("catch exception,err_msg:%s" % traceback.format_exc()) + return [] diff --git a/search/views/__pycache__/__init__.cpython-36.pyc b/search/views/__pycache__/__init__.cpython-36.pyc deleted file mode 100644 index 17ab141852e3e656fdb05042a66bbfe828af291e..0000000000000000000000000000000000000000 Binary files a/search/views/__pycache__/__init__.cpython-36.pyc and /dev/null differ diff --git a/search/views/__pycache__/pick.cpython-36.pyc b/search/views/__pycache__/pick.cpython-36.pyc deleted file mode 100644 index f786bba841fa468ad2078db86c30729fed4eea47..0000000000000000000000000000000000000000 Binary files a/search/views/__pycache__/pick.cpython-36.pyc and /dev/null differ diff --git a/search/views/__pycache__/topic.cpython-36.pyc b/search/views/__pycache__/topic.cpython-36.pyc deleted file mode 100644 index 5340961a73ddd171d38435a152790543f080bc05..0000000000000000000000000000000000000000 Binary files a/search/views/__pycache__/topic.cpython-36.pyc and /dev/null differ diff --git a/search/views/topic.py b/search/views/topic.py index e3aef4773bf61cd8ed7e5a946ac23ce47b7829fc..4089a5ae8ef48a76677487dd63d240f4c38c6c8c 100644 --- a/search/views/topic.py +++ b/search/views/topic.py @@ -254,3 +254,15 @@ def query_topic_by_tag_aggregation(user_id,tag_id, offset, size): return {"recommend_topic_id": []} +@bind("physical/search/topic") +def topic_search(filters, nfilters=None, sorts_by=None, offset=0, size=10): + """å¸–åæœç´¢ã€‚""" + + try: + result_list = TopicUtils.list_topic_ids(filters=filters, nfilters=nfilters, + sorts_by=sorts_by, offset=offset, size=size) + topic_ids = [item["_source"]["id"] for item in result_list] + return {"topic_ids": topic_ids} + except: + logging.error("catch exception, err_msg:%s" % traceback.format_exc()) + return {"topic_ids": []} diff --git a/trans2es/management/commands/__pycache__/trans2es_data2es_parallel.cpython-36.pyc b/trans2es/management/commands/__pycache__/trans2es_data2es_parallel.cpython-36.pyc deleted file mode 100644 index 5ffbae455316852e084db46df6d107e69e6f3120..0000000000000000000000000000000000000000 Binary files a/trans2es/management/commands/__pycache__/trans2es_data2es_parallel.cpython-36.pyc and /dev/null differ diff --git a/trans2es/management/commands/__pycache__/trans2es_mapping2es.cpython-36.pyc b/trans2es/management/commands/__pycache__/trans2es_mapping2es.cpython-36.pyc deleted file mode 100644 index 3f481159a80d2942505d1f615801f2db07a3f9db..0000000000000000000000000000000000000000 Binary files a/trans2es/management/commands/__pycache__/trans2es_mapping2es.cpython-36.pyc and /dev/null differ diff --git a/trans2es/migrations/__pycache__/__init__.cpython-36.pyc b/trans2es/migrations/__pycache__/__init__.cpython-36.pyc deleted file mode 100644 index 22e6eff7fa14aca7f66de01d21fcb26f5295f0d2..0000000000000000000000000000000000000000 Binary files a/trans2es/migrations/__pycache__/__init__.cpython-36.pyc and /dev/null differ diff --git a/trans2es/models/__pycache__/__init__.cpython-36.pyc b/trans2es/models/__pycache__/__init__.cpython-36.pyc deleted file mode 100644 index 653e03af27593fb7589d815afc13275d5432961c..0000000000000000000000000000000000000000 Binary files a/trans2es/models/__pycache__/__init__.cpython-36.pyc and /dev/null differ diff --git a/trans2es/models/__pycache__/diary.cpython-36.pyc b/trans2es/models/__pycache__/diary.cpython-36.pyc deleted file mode 100644 index 40a35f19087badf8a555449b08bbc7186ea2346b..0000000000000000000000000000000000000000 Binary files a/trans2es/models/__pycache__/diary.cpython-36.pyc and /dev/null differ diff --git a/trans2es/models/__pycache__/group.cpython-36.pyc b/trans2es/models/__pycache__/group.cpython-36.pyc deleted file mode 100644 index eecf2a2b81e6d1dab56ab9351d5272968a0e4f3a..0000000000000000000000000000000000000000 Binary files a/trans2es/models/__pycache__/group.cpython-36.pyc and /dev/null differ diff --git a/trans2es/models/__pycache__/group_user_role.cpython-36.pyc b/trans2es/models/__pycache__/group_user_role.cpython-36.pyc deleted file mode 100644 index 12aefeb09532fa082d4af04cdd0c826590503846..0000000000000000000000000000000000000000 Binary files a/trans2es/models/__pycache__/group_user_role.cpython-36.pyc and /dev/null differ diff --git a/trans2es/models/__pycache__/pick_celebrity.cpython-36.pyc b/trans2es/models/__pycache__/pick_celebrity.cpython-36.pyc deleted file mode 100644 index d0aa040b9af7105d5a25e5b6becbdf439176c6d4..0000000000000000000000000000000000000000 Binary files a/trans2es/models/__pycache__/pick_celebrity.cpython-36.pyc and /dev/null differ diff --git a/trans2es/models/__pycache__/pick_topic.cpython-36.pyc b/trans2es/models/__pycache__/pick_topic.cpython-36.pyc deleted file mode 100644 index 743389167e9937a014bcbd1902c15759f99a9b74..0000000000000000000000000000000000000000 Binary files a/trans2es/models/__pycache__/pick_topic.cpython-36.pyc and /dev/null differ diff --git a/trans2es/models/__pycache__/pickuserrecord.cpython-36.pyc b/trans2es/models/__pycache__/pickuserrecord.cpython-36.pyc deleted file mode 100644 index 3c7381a3cbb1160e72a036774ddacca63f10612c..0000000000000000000000000000000000000000 Binary files a/trans2es/models/__pycache__/pickuserrecord.cpython-36.pyc and /dev/null differ diff --git a/trans2es/models/__pycache__/tag.cpython-36.pyc b/trans2es/models/__pycache__/tag.cpython-36.pyc deleted file mode 100644 index aa70dd64d9b179077176b26c5d82ac3915458823..0000000000000000000000000000000000000000 Binary files a/trans2es/models/__pycache__/tag.cpython-36.pyc and /dev/null differ diff --git a/trans2es/models/__pycache__/topic.cpython-36.pyc b/trans2es/models/__pycache__/topic.cpython-36.pyc deleted file mode 100644 index bd36cbc57c63965709a040b9d3ca5d719b12cef6..0000000000000000000000000000000000000000 Binary files a/trans2es/models/__pycache__/topic.cpython-36.pyc and /dev/null differ diff --git a/trans2es/models/__pycache__/user.cpython-36.pyc b/trans2es/models/__pycache__/user.cpython-36.pyc deleted file mode 100644 index c67621fea96658e5b1ff5bc6d44f881f837d5693..0000000000000000000000000000000000000000 Binary files a/trans2es/models/__pycache__/user.cpython-36.pyc and /dev/null differ diff --git a/trans2es/models/__pycache__/user_follow.cpython-36.pyc b/trans2es/models/__pycache__/user_follow.cpython-36.pyc deleted file mode 100644 index 2a1eaba5193b919053b033cd77ea7f49f1acef11..0000000000000000000000000000000000000000 Binary files a/trans2es/models/__pycache__/user_follow.cpython-36.pyc and /dev/null differ diff --git a/trans2es/utils/__pycache__/diary_transfer.cpython-36.pyc b/trans2es/utils/__pycache__/diary_transfer.cpython-36.pyc deleted file mode 100644 index bfc40fcd85bf390d856e4182f6f9eb46d36b5d57..0000000000000000000000000000000000000000 Binary files a/trans2es/utils/__pycache__/diary_transfer.cpython-36.pyc and /dev/null differ diff --git a/trans2es/utils/__pycache__/pick_celebrity_transfer.cpython-36.pyc b/trans2es/utils/__pycache__/pick_celebrity_transfer.cpython-36.pyc deleted file mode 100644 index 39031e41e23ac54e10da70b1e6789f8f3b158d80..0000000000000000000000000000000000000000 Binary files a/trans2es/utils/__pycache__/pick_celebrity_transfer.cpython-36.pyc and /dev/null differ diff --git a/trans2es/utils/__pycache__/topic_transfer.cpython-36.pyc b/trans2es/utils/__pycache__/topic_transfer.cpython-36.pyc deleted file mode 100644 index 4ee5284c9200b73c438baccb0704c73ec4cc5a9d..0000000000000000000000000000000000000000 Binary files a/trans2es/utils/__pycache__/topic_transfer.cpython-36.pyc and /dev/null differ diff --git a/trans2es/utils/__pycache__/user_transfer.cpython-36.pyc b/trans2es/utils/__pycache__/user_transfer.cpython-36.pyc deleted file mode 100644 index b6f965482fefa286f20308014f87818cf3880be5..0000000000000000000000000000000000000000 Binary files a/trans2es/utils/__pycache__/user_transfer.cpython-36.pyc and /dev/null differ