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
钟尚武
physical
Commits
fe3f0cc3
Commit
fe3f0cc3
authored
Mar 15, 2019
by
段英荣
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'similar_sort' into 'master'
modify See merge request
alpha/physical!177
parents
884099cf
448708f3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
38 deletions
+39
-38
topic.py
search/utils/topic.py
+38
-37
topic.py
search/views/topic.py
+1
-1
No files found.
search/utils/topic.py
View file @
fe3f0cc3
...
...
@@ -167,15 +167,15 @@ class TopicUtils(object):
},
"weight"
:
3
},
#
{
#
"linear": {
#
"create_time": {
#
"scale": "1d",
#
"decay": 0.99
#
}
#
},
#
"weight": 500
#
}
{
"linear"
:
{
"create_time"
:
{
"scale"
:
"1d"
,
"decay"
:
0.99
}
},
"weight"
:
500
}
]
if
len
(
user_similar_score_list
)
>
0
:
...
...
@@ -301,14 +301,13 @@ class TopicUtils(object):
query_function_score
[
"query"
][
"bool"
][
"minimum_should_match"
]
=
1
q
[
"query"
][
"function_score"
]
=
query_function_score
#
q["collapse"] = {
#
"field": "user_id"
#
}
q
[
"collapse"
]
=
{
"field"
:
"user_id"
}
q
[
"_source"
]
=
{
"includes"
:[
"id"
,
"group_id"
,
"offline_score"
,
"user_id"
,
"edit_tag_list"
]
}
q
[
"sort"
]
=
[
"create_time_val"
,
{
"_script"
:{
"type"
:
"number"
,
...
...
@@ -331,30 +330,32 @@ class TopicUtils(object):
same_user_id_set
=
set
()
for
item
in
result_dict
[
"hits"
]:
if
item
[
"_source"
][
"group_id"
]
>
0
and
item
[
"_source"
][
"group_id"
]
not
in
same_group_id_set
:
same_group_id_set
.
add
(
item
[
"_source"
][
"id"
])
topic_id_list
.
append
(
item
[
"_source"
][
"id"
])
else
:
same_group_id_set
.
add
(
item
[
"_source"
][
"id"
])
if
item
[
"_source"
][
"user_id"
]
not
in
same_user_id_set
:
same_user_id_set
.
add
(
item
[
"_source"
][
"id"
])
topic_id_list
.
append
(
item
[
"_source"
][
"id"
])
else
:
same_user_id_set
.
add
(
item
[
"_source"
][
"id"
])
if
len
(
topic_id_list
)
>=
single_size
:
break
if
len
(
topic_id_list
)
<
single_size
:
for
topic_id
in
same_group_id_set
:
topic_id_list
.
append
(
topic_id
)
if
len
(
topic_id_list
)
>=
single_size
:
break
for
topic_id
in
same_user_id_set
:
topic_id_list
.
append
(
topic_id
)
if
len
(
topic_id_list
)
>=
single_size
:
break
topic_id_list
.
append
(
item
[
"_source"
][
"id"
])
# for item in result_dict["hits"]:
# if item["_source"]["group_id"]>0 and item["_source"]["group_id"] not in same_group_id_set:
# same_group_id_set.add(item["_source"]["id"])
# topic_id_list.append(item["_source"]["id"])
# else:
# same_group_id_set.add(item["_source"]["id"])
#
# if item["_source"]["user_id"] not in same_user_id_set:
# same_user_id_set.add(item["_source"]["id"])
# topic_id_list.append(item["_source"]["id"])
# else:
# same_user_id_set.add(item["_source"]["id"])
#
# if len(topic_id_list) >= single_size:
# break
#
# if len(topic_id_list) < single_size:
# for topic_id in same_group_id_set:
# topic_id_list.append(topic_id)
# if len(topic_id_list)>=single_size:
# break
# for topic_id in same_user_id_set:
# topic_id_list.append(topic_id)
# if len(topic_id_list)>=single_size:
# break
return
topic_id_list
except
:
...
...
search/views/topic.py
View file @
fe3f0cc3
...
...
@@ -80,7 +80,7 @@ def get_home_recommend_topic_ids(user_id, device_id, tag_id, offset, size, query
user_similar_score_redis_list
=
json
.
loads
(
redis_user_similar_score_redis_val
)
if
redis_user_similar_score_redis_val
else
[]
topic_id_list
=
TopicUtils
.
get_recommend_topic_ids
(
user_id
=
user_id
,
tag_id
=
tag_id
,
offset
=
offset
,
size
=
size
*
size
,
topic_id_list
=
TopicUtils
.
get_recommend_topic_ids
(
user_id
=
user_id
,
tag_id
=
tag_id
,
offset
=
offset
,
size
=
size
,
single_size
=
size
,
query
=
query
,
query_type
=
query_type
,
filter_topic_id_list
=
have_read_topic_id_list
,
recommend_tag_list
=
recommend_tag_list
,
...
...
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