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
1c03f85a
Commit
1c03f85a
authored
Apr 22, 2019
by
lixiaofang
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'test' of git.wanmeizhensuo.com:alpha/physical into test
parents
b14bafa0
06905909
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
21 deletions
+24
-21
topic.py
search/utils/topic.py
+19
-19
topic.py
search/views/topic.py
+5
-2
No files found.
search/utils/topic.py
View file @
1c03f85a
...
@@ -445,7 +445,7 @@ class TopicUtils(object):
...
@@ -445,7 +445,7 @@ class TopicUtils(object):
q
=
dict
()
q
=
dict
()
q
[
"query"
]
=
dict
()
q
[
"query"
]
=
dict
()
logging
.
warning
(
"topic_tag_list:
%
s"
%
str
(
topic_tag_list
))
#
logging.warning("topic_tag_list:%s"%str(topic_tag_list))
functions_list
=
[
functions_list
=
[
{
{
"linear"
:
{
"linear"
:
{
...
@@ -456,23 +456,23 @@ class TopicUtils(object):
...
@@ -456,23 +456,23 @@ class TopicUtils(object):
}
}
}
}
]
]
if
len
(
topic_tag_list
)
>
0
:
#
if len(topic_tag_list) > 0:
functions_list
.
append
(
#
functions_list.append(
{
#
{
"filter"
:
{
"bool"
:
{
#
"filter": {"bool": {
"should"
:
{
"terms"
:
{
"tag_list"
:
topic_tag_list
}}}},
#
"should": {"terms": {"tag_list": topic_tag_list}}}},
"weight"
:
5000
#
"weight": 5000
}
#
}
)
#
)
if
topic_user_id
!=
-
1
:
#
if topic_user_id != -1:
functions_list
.
append
(
#
functions_list.append(
{
#
{
"filter"
:
{
"bool"
:
{
#
"filter": {"bool": {
"should"
:
{
"term"
:
{
"user_id"
:
topic_user_id
}}}},
#
"should": {"term": {"user_id": topic_user_id}}}},
"weight"
:
5000
#
"weight": 5000
}
#
}
)
#
)
if
len
(
topic_tag_list
)
!=
0
or
user_id
!=
-
1
:
if
len
(
topic_tag_list
)
!=
0
or
topic_
user_id
!=
-
1
:
query_function_score
=
{
query_function_score
=
{
"query"
:
{
"query"
:
{
"bool"
:
{
"bool"
:
{
...
@@ -520,7 +520,7 @@ class TopicUtils(object):
...
@@ -520,7 +520,7 @@ class TopicUtils(object):
}
}
}
}
if
topic_user_id
!=
-
1
:
if
topic_user_id
!=
-
1
:
query_function_score
[
"query"
][
"bool"
][
"
should"
]
=
{
query_function_score
[
"query"
][
"bool"
][
"
must"
]
+
=
{
"term"
:
{
"term"
:
{
"user_id"
:
topic_user_id
"user_id"
:
topic_user_id
}
}
...
...
search/views/topic.py
View file @
1c03f85a
...
@@ -300,8 +300,8 @@ def topic_detail_page_recommend(device_id="", user_id=-1, topic_id=-1, topic_pic
...
@@ -300,8 +300,8 @@ def topic_detail_page_recommend(device_id="", user_id=-1, topic_id=-1, topic_pic
if
topic_user_id
!=
-
1
:
if
topic_user_id
!=
-
1
:
topic_user_result
=
TopicUtils
.
top_get_topic_detail_recommend_list
(
user_id
,
topic_id
,
have_read_topic_list
,
topic_user_result
=
TopicUtils
.
top_get_topic_detail_recommend_list
(
user_id
,
topic_id
,
have_read_topic_list
,
size
,
es_cli_obj
,
size
,
es_cli_obj
,
index_type
=
"topic"
,
routing
=
"4,5,6"
,
index_type
=
"topic"
,
routing
=
"4,5,6"
,
topic_user_id
=
topic_user_id
topic_tag_list
=
topic_tag_list
)
)
topic_user_size
=
len
(
topic_user_result
)
topic_user_size
=
len
(
topic_user_result
)
have_read_topic_list
.
extend
(
topic_user_result
)
have_read_topic_list
.
extend
(
topic_user_result
)
if
topic_user_size
<
size
:
if
topic_user_size
<
size
:
...
@@ -342,6 +342,9 @@ def topic_detail_page_recommend(device_id="", user_id=-1, topic_id=-1, topic_pic
...
@@ -342,6 +342,9 @@ def topic_detail_page_recommend(device_id="", user_id=-1, topic_id=-1, topic_pic
redis_client
.
expire
(
redis_key
,
60
*
60
*
24
)
redis_client
.
expire
(
redis_key
,
60
*
60
*
24
)
result_list
=
[]
result_list
=
[]
logging
.
warning
(
"topic_tag_result:
%
s"
%
str
(
topic_tag_result
))
logging
.
warning
(
"topic_user_result:
%
s"
%
str
(
topic_user_result
))
logging
.
warning
(
"result:
%
s"
%
str
(
result
))
recommend_topic_ids_list
=
list
()
recommend_topic_ids_list
=
list
()
recommend_topic_ids_list
.
extend
(
topic_tag_result
)
recommend_topic_ids_list
.
extend
(
topic_tag_result
)
recommend_topic_ids_list
.
extend
(
topic_user_result
)
recommend_topic_ids_list
.
extend
(
topic_user_result
)
...
...
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