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
ddf4c872
Commit
ddf4c872
authored
Sep 26, 2019
by
lixiaofang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add
parent
221dce25
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
22 deletions
+26
-22
topic.py
search/utils/topic.py
+26
-22
No files found.
search/utils/topic.py
View file @
ddf4c872
...
...
@@ -12,6 +12,7 @@ from search.utils.common import *
from
trans2es.models.pictorial
import
PictorialTopics
from
libs.cache
import
redis_client
class
TopicUtils
(
object
):
@classmethod
...
...
@@ -320,7 +321,7 @@ class TopicUtils(object):
'type'
:
'best_fields'
,
'operator'
:
'or'
,
'fields'
:
[
"content"
,
"tag_name_list"
],
"analyzer"
:
"gm_default_index"
"analyzer"
:
"gm_default_index"
}
query_function_score
[
"boost_mode"
]
=
"replace"
...
...
@@ -335,13 +336,14 @@ class TopicUtils(object):
{
"range"
:
{
"content_level"
:
{
"gte"
:
3
,
"lte"
:
6
}}}
)
collection_redis_key_name
=
"physical:official_tag_name_set"
collect_tag_name_set
=
set
()
collection_redis_key_name
=
"physical:official_tag_name_set"
collect_tag_name_set
=
set
()
body
=
{
'text'
:
query
,
'analyzer'
:
"gm_default_search"
}
analyze_res
=
ESPerform
.
get_analyze_results
(
es_cli
=
ESPerform
.
get_cli
(),
sub_index_name
=
"topic"
,
query_body
=
body
)
analyze_res
=
ESPerform
.
get_analyze_results
(
es_cli
=
ESPerform
.
get_cli
(),
sub_index_name
=
"topic"
,
query_body
=
body
)
for
item
in
analyze_res
[
"tokens"
]:
token_word
=
item
[
"token"
]
# is_member = redis_client.sismember(collection_redis_key_name, token_word)
...
...
@@ -357,10 +359,10 @@ class TopicUtils(object):
}
functions_list
+=
[
{
"weight"
:
10
,
"filter"
:{
"term"
:{
"language_type"
:
1
"weight"
:
10
,
"filter"
:
{
"term"
:
{
"language_type"
:
1
}
}
},
...
...
@@ -434,9 +436,9 @@ class TopicUtils(object):
topic_id_list
.
append
(
item
[
"_source"
][
"id"
])
if
has_score
:
return
topic_id_list
,
ret_data_list
,
topic_score_list
return
topic_id_list
,
ret_data_list
,
topic_score_list
else
:
return
topic_id_list
,
ret_data_list
return
topic_id_list
,
ret_data_list
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
if
has_score
:
...
...
@@ -444,7 +446,6 @@ class TopicUtils(object):
else
:
return
list
(),
list
()
@classmethod
def
userful_tag_topic_list
(
cls
,
user_id
,
have_read_topic_list
,
size
,
index_type
=
"topic-high-star"
,
routing
=
None
,
useful_tag_list
=
[]):
...
...
@@ -528,10 +529,9 @@ class TopicUtils(object):
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
[]
@classmethod
def
get_linucb_topic_info_for_debug
(
cls
,
size
,
index_type
=
"topic-high-star"
,
routing
=
None
,
linucb_topic_list
=
[]):
index_type
=
"topic-high-star"
,
routing
=
None
,
linucb_topic_list
=
[]):
try
:
es_cli_obj
=
ESPerform
.
get_cli
()
if
len
(
linucb_topic_list
)
==
0
:
...
...
@@ -546,22 +546,22 @@ class TopicUtils(object):
}
}
q
[
"_source"
]
=
{
"includes"
:
[
"id"
,
"content_level"
,
"edit_tag_list"
]
"includes"
:
[
"id"
,
"content_level"
,
"edit_tag_list"
]
}
result_dict
=
ESPerform
.
get_search_results
(
es_cli_obj
,
sub_index_name
=
index_type
,
query_body
=
q
,
size
=
size
,
routing
=
"6"
)
topic_id_dict
=
dict
()
for
item
in
result_dict
[
"hits"
]:
topic_id_dict
.
update
({
item
[
"_source"
][
"id"
]:{
"content_level"
:
item
[
"_source"
][
"content_level"
],
"edit_tag_list"
:
item
[
"_source"
][
"edit_tag_list"
]}})
topic_id_dict
.
update
({
item
[
"_source"
][
"id"
]:
{
"content_level"
:
item
[
"_source"
][
"content_level"
],
"edit_tag_list"
:
item
[
"_source"
][
"edit_tag_list"
]}})
return
topic_id_dict
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
[]
@classmethod
def
get_linucb_pictorial_info_for_debug
(
cls
,
size
,
linucb_pictorial_list
=
[]):
def
get_linucb_pictorial_info_for_debug
(
cls
,
size
,
linucb_pictorial_list
=
[]):
try
:
q
=
{
"query"
:
{
...
...
@@ -593,8 +593,6 @@ class TopicUtils(object):
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
list
()
@classmethod
def
get_topic_detail_recommend_list
(
cls
,
user_id
,
topic_id
,
topic_tag_list
,
topic_pictorial_id
,
topic_user_id
,
filter_topic_user_id
,
have_read_topic_list
,
offset
,
size
,
es_cli_obj
=
None
,
...
...
@@ -794,9 +792,9 @@ class TopicUtils(object):
# "includes": ["id", "pictorial_id", "user_id", "_score", "create_time", "content_level"]
q
[
'sort'
]
=
[
{
"latest_reply_time"
:
{
"order"
:
"desc"
}},
# {"create_time": {"order": "desc"}}
]
{
"latest_reply_time"
:
{
"order"
:
"desc"
}},
# {"create_time": {"order": "desc"}}
]
result_dict
=
ESPerform
.
get_search_results
(
es_cli_obj
,
sub_index_name
=
index_type
,
query_body
=
q
,
size
=
size
,
routing
=
routing
)
...
...
@@ -1294,6 +1292,12 @@ class TopicUtils(object):
"query"
:
v
}
})
elif
k
==
"is_shadow"
:
f
.
append
({
"term"
:
{
"is_shadow"
:
False
}
})
elif
k
==
"virtual_content_level"
:
f
.
append
({
...
...
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