Commit d2232936 authored by 段英荣's avatar 段英荣

modify linucb es bug

parent 741157fd
...@@ -276,18 +276,22 @@ class ESPerform(object): ...@@ -276,18 +276,22 @@ class ESPerform(object):
) )
q = { q = {
"query":{ "query":{
"bool":{ "function_score":{
"must":[ "query": {
{"range": {"content_level": {"gte": 3, "lte": 5}}}, "bool": {
{"term":{"is_online": True}}, "must": [
{"term":{"is_deleted": False}}, {"range": {"content_level": {"gte": 3, "lte": 5}}},
{"terms":{"tag_list":tag_id}} {"term": {"is_online": True}},
] {"term": {"is_deleted": False}},
{"terms": {"tag_list": tag_id}}
]
}
},
"boost_mode": "sum",
"score_mode": "sum",
"functions": functions_list
} }
}, },
"boost_mode": "sum",
"score_mode": "sum",
"functions": functions_list,
"_source":{ "_source":{
"include":["id"] "include":["id"]
}, },
...@@ -298,7 +302,11 @@ class ESPerform(object): ...@@ -298,7 +302,11 @@ class ESPerform(object):
] ]
} }
if len(have_read_topic_id_list)>0: if len(have_read_topic_id_list)>0:
q["query"]["bool"]["must_not"] = have_read_topic_id_list q["query"]["bool"]["must_not"] = {
"terms":{
"id":have_read_topic_id_list
}
}
result_dict = ESPerform.get_search_results(ESPerform.get_cli(), sub_index_name="topic", query_body=q, result_dict = ESPerform.get_search_results(ESPerform.get_cli(), sub_index_name="topic", query_body=q,
offset=0, size=100,routing="3,4,5") offset=0, size=100,routing="3,4,5")
......
...@@ -24,34 +24,6 @@ def get_highlight(fields=[]): ...@@ -24,34 +24,6 @@ def get_highlight(fields=[]):
@bind("physical/search/query_tag") @bind("physical/search/query_tag")
def query_tag(query,offset,size): def query_tag(query,offset,size):
try: try:
"""
q = {
"query":{
"bool":{
"must":[
{"term":{"is_online":True}},
{"term": {"is_deleted": False}}
],
"should":[
{"multi_match":{
"query": query,
"fields":["name"],
"operator":"and"}}
],
"minimum_should_match":1
}
},
"sort":[
{"near_new_topic_num":{"order":"desc"}},
{'_score': {"order": "desc"}}
],
"_source": {
"includes": ["id", "name"]
}
}
q["highlight"] = get_highlight(["name"])
"""
q = { q = {
"suggest":{ "suggest":{
"tips-suggest":{ "tips-suggest":{
...@@ -121,3 +93,11 @@ def query_by_tag_type(tag_type_id,offset,size): ...@@ -121,3 +93,11 @@ def query_by_tag_type(tag_type_id,offset,size):
logging.error("catch exception,err_msg:%s" % traceback.format_exc()) logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return {"tag_list": []} return {"tag_list": []}
@bind("physical/search/choice_push_tag")
def choice_push_tag(device_id,user_id):
try:
pass
except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return {"tag_list": []}
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