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
279e49ab
Commit
279e49ab
authored
Jun 13, 2019
by
lixiaofang
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into hotword
parents
8c600a7b
580c06fe
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
23 deletions
+22
-23
topic.py
search/utils/topic.py
+19
-19
topic.py
trans2es/models/topic.py
+3
-4
No files found.
search/utils/topic.py
View file @
279e49ab
...
@@ -260,7 +260,7 @@ class TopicUtils(object):
...
@@ -260,7 +260,7 @@ class TopicUtils(object):
query_fields
=
[
'^'
.
join
((
k
,
str
(
v
)))
for
(
k
,
v
)
in
multi_fields
.
items
()]
query_fields
=
[
'^'
.
join
((
k
,
str
(
v
)))
for
(
k
,
v
)
in
multi_fields
.
items
()]
multi_match
=
{
multi_match
=
{
'query'
:
query
,
'query'
:
query
,
'type'
:
'
cross
_fields'
,
'type'
:
'
best
_fields'
,
'operator'
:
'and'
,
'operator'
:
'and'
,
'fields'
:
query_fields
,
'fields'
:
query_fields
,
}
}
...
@@ -337,7 +337,7 @@ class TopicUtils(object):
...
@@ -337,7 +337,7 @@ class TopicUtils(object):
@classmethod
@classmethod
def
userful_tag_topic_list
(
cls
,
user_id
,
have_read_topic_list
,
size
,
def
userful_tag_topic_list
(
cls
,
user_id
,
have_read_topic_list
,
size
,
index_type
=
"topic-high-star"
,
routing
=
None
):
index_type
=
"topic-high-star"
,
routing
=
None
,
useful_tag_list
=
[]
):
"""
"""
:remark 帖子详情页推荐列表,缺少按时间衰减
:remark 帖子详情页推荐列表,缺少按时间衰减
:param user_id:
:param user_id:
...
@@ -350,22 +350,22 @@ class TopicUtils(object):
...
@@ -350,22 +350,22 @@ class TopicUtils(object):
"""
"""
try
:
try
:
es_cli_obj
=
ESPerform
.
get_cli
()
es_cli_obj
=
ESPerform
.
get_cli
()
useful_tag_list
=
list
()
#
useful_tag_list = list()
q
=
dict
()
#
q = dict()
q
[
"query"
]
=
{
#
q["query"] = {
"term"
:
{
#
"term": {
"user_id"
:
user_id
#
"user_id": user_id
}
#
}
}
#
}
#
q
[
"_source"
]
=
{
#
q["_source"] = {
"include"
:
[
"useful_tag_list"
]
#
"include": ["useful_tag_list"]
}
#
}
result_dict
=
ESPerform
.
get_search_results
(
es_cli_obj
,
"user"
,
q
,
0
,
1
)
#
result_dict = ESPerform.get_search_results(es_cli_obj, "user", q, 0, 1)
if
len
(
result_dict
[
"hits"
])
==
0
:
#
if len(result_dict["hits"]) == 0:
logging
.
warning
(
"not find user_id:
%
d in es!"
%
int
(
user_id
))
#
logging.warning("not find user_id:%d in es!" % int(user_id))
else
:
#
else:
useful_tag_list
=
result_dict
[
"hits"
][
0
][
"_source"
][
"useful_tag_list"
]
#
useful_tag_list = result_dict["hits"][0]["_source"]["useful_tag_list"]
if
len
(
useful_tag_list
)
==
0
:
if
len
(
useful_tag_list
)
==
0
:
return
[]
return
[]
else
:
else
:
...
@@ -375,7 +375,7 @@ class TopicUtils(object):
...
@@ -375,7 +375,7 @@ class TopicUtils(object):
"must"
:
[
"must"
:
[
{
"term"
:
{
"is_online"
:
True
}},
{
"term"
:
{
"is_online"
:
True
}},
{
"term"
:
{
"is_deleted"
:
False
}},
{
"term"
:
{
"is_deleted"
:
False
}},
{
"terms"
:
{
"tag_list"
:
useful_tag_list
}},
{
"terms"
:
{
"
useful_
tag_list"
:
useful_tag_list
}},
{
"term"
:{
"content_level"
:
6
}}
{
"term"
:{
"content_level"
:
6
}}
],
],
"must_not"
:
{
"must_not"
:
{
...
...
trans2es/models/topic.py
View file @
279e49ab
...
@@ -206,10 +206,9 @@ class Topic(models.Model):
...
@@ -206,10 +206,9 @@ class Topic(models.Model):
def
get_tag_name_list
(
self
,
tag_id_list
):
def
get_tag_name_list
(
self
,
tag_id_list
):
try
:
try
:
tag_name_list
=
list
()
tag_name_list
=
list
()
for
i
in
range
(
0
,
len
(
tag_name_list
),
1000
):
for
i
in
range
(
0
,
len
(
tag_id_list
),
100
):
query_results
=
Tag
.
objects
.
using
(
settings
.
SLAVE_DB_NAME
)
.
filter
(
id__in
=
tag_id_list
[
i
:
i
+
1000
])
query_terms_list
=
list
(
Tag
.
objects
.
using
(
settings
.
SLAVE_DB_NAME
)
.
filter
(
id__in
=
tag_id_list
[
i
:
i
+
100
],
is_online
=
True
,
is_deleted
=
False
)
.
values_list
(
"name"
,
flat
=
True
))
for
item
in
query_results
:
tag_name_list
.
extend
(
query_terms_list
)
tag_name_list
.
append
(
item
)
return
tag_name_list
return
tag_name_list
except
:
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
...
...
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