Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
P
physical
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
alpha
physical
Commits
ab9838ed
Commit
ab9838ed
authored
Dec 01, 2018
by
段英荣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modify
parent
fb058dde
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
62 additions
and
3 deletions
+62
-3
app_conf.xml
app_conf.xml
+1
-0
topic.py
search/utils/topic.py
+57
-1
topic.py
search/views/topic.py
+4
-2
No files found.
app_conf.xml
View file @
ab9838ed
...
...
@@ -10,5 +10,6 @@
<element
value=
"physical.django_init"
/>
<element
value=
"search.views.topic"
/>
<element
value=
"search.views.pick"
/>
<element
value=
"search.views.group"
/>
</config>
</gm_rpcd_config>
search/utils/topic.py
View file @
ab9838ed
...
...
@@ -32,7 +32,7 @@ class TopicUtils(object):
return
result_dict
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
None
return
[]
@classmethod
...
...
@@ -229,3 +229,58 @@ class TopicUtils(object):
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
([],[])
@classmethod
def
get_topic_detail_recommend
(
cls
,
user_id
,
user_tag_list
,
topic_group_id
,
topic_user_id
,
offset
,
size
):
"""
:remark 帖子详情页推荐策略,缺少按时间衰减
:param user_id:
:param user_tag_list:
:param topic_group_id:
:param topic_user_id:
:param offset:
:param size:
:return:
"""
try
:
q
=
dict
()
q
[
"query"
]
=
dict
()
functions_list
=
[
{
"filter"
:
{
"term"
:
{
"group_id"
:
topic_group_id
}},
"weight"
:
1
,
},
{
"filter"
:
{
"term"
:
{
"user_id"
:
topic_user_id
}},
"weight"
:
1000
}
]
query_tag_term_list
=
cls
.
___get_should_term_list
(
user_tag_list
)
query_function_score
=
{
"query"
:{
"bool"
:{
"should"
:
query_tag_term_list
,
"must"
:
{
"range"
:
{
"content_level"
:
{
"gte"
:
3
,
"lte"
:
5
}}
}
}
},
"score_mode"
:
"sum"
,
"boost_mode"
:
"sum"
,
"functions"
:
functions_list
}
q
[
"query"
][
"function_score"
]
=
query_function_score
q
[
"_source"
]
=
{
"include"
:[
"id"
,
"group_id"
,
"user_id"
,
"_score"
]
}
result_dict
=
ESPerform
.
get_search_results
(
ESPerform
.
get_cli
(),
sub_index_name
=
"topic"
,
query_body
=
q
,
offset
=
offset
,
size
=
size
)
return
result_dict
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
[]
\ No newline at end of file
search/views/topic.py
View file @
ab9838ed
...
...
@@ -83,8 +83,8 @@ def home_query(user_id=-1,query="",offset=0,size=10):
if
len
(
redis_val_dict
)
>
0
:
group_topic_ids
=
json
.
loads
(
redis_val_dict
[
b
"group_topic_ids"
])
not_group_topic_ids
=
json
.
loads
(
redis_val_dict
[
b
"not_group_topic_ids"
])
group_topic_ids_index
=
redis_val_dict
[
b
"group_topic_ids_index"
]
not_group_topic_ids_index
=
redis_val_dict
[
b
"not_group_topic_ids_index"
]
group_topic_ids_index
=
int
(
redis_val_dict
[
b
"group_topic_ids_index"
])
not_group_topic_ids_index
=
int
(
redis_val_dict
[
b
"not_group_topic_ids_index"
])
if
len
(
group_topic_ids
)
<
(
size
-
1
)
or
len
(
not_group_topic_ids
)
<
1
:
if
len
(
group_topic_ids
)
<
(
size
-
1
):
...
...
@@ -136,6 +136,8 @@ def topic_detail_page_recommend(user_id=-1,topic_id=-1,topic_group_id=-1,topic_u
:return:
"""
try
:
user_tag_list
=
list
()
result_dict
=
TopicUtils
.
get_topic_detail_recommend
(
user_id
,
user_tag_list
,
topic_group_id
,
topic_user_id
,
offset
,
size
)
return
{
"recommend_topic_ids"
:
[]}
except
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment