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
e0dc1c54
Commit
e0dc1c54
authored
Apr 11, 2019
by
Kai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
2b2f87fb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
25 deletions
+29
-25
es.py
libs/es.py
+14
-11
collect_data.py
linucb/views/collect_data.py
+15
-14
No files found.
libs/es.py
View file @
e0dc1c54
...
@@ -264,27 +264,28 @@ class ESPerform(object):
...
@@ -264,27 +264,28 @@ class ESPerform(object):
return
True
return
True
@classmethod
@classmethod
def
get_tag_topic_list
(
cls
,
tag_id
):
def
get_tag_topic_list
(
cls
,
tag_id
,
have_read_topic_id_list
):
for
id
in
tag_id
:
functions_list
.
append
(
{
"filter"
:
{
"term"
:
{
"tag_list"
:
id
}},
"weight"
:
1
}
)
try
:
try
:
functions_list
=
list
()
for
id
in
tag_id
:
functions_list
.
append
(
{
"filter"
:
{
"term"
:
{
"tag_list"
:
id
}},
"weight"
:
1
}
)
q
=
{
q
=
{
"query"
:{
"query"
:{
"bool"
:{
"bool"
:{
"must"
:[
"must"
:[
{
"range"
:
{
"content_level"
:
{
"gte"
:
4
,
"lte"
:
5
}}},
{
"range"
:
{
"content_level"
:
{
"gte"
:
3
,
"lte"
:
5
}}},
{
"term"
:{
"is_online"
:
True
}},
{
"term"
:{
"is_online"
:
True
}},
{
"term"
:{
"is_deleted"
:
False
}},
{
"term"
:{
"is_deleted"
:
False
}},
{
"terms"
:{
"tag_list"
:
tag_id
}}
{
"terms"
:{
"tag_list"
:
tag_id
}}
]
]
}
}
},
},
"boost_mode"
:
"sum"
,
"score_mode"
:
"sum"
,
"score_mode"
:
"sum"
,
"functions"
:
functions_list
,
"functions"
:
functions_list
,
"_source"
:{
"_source"
:{
...
@@ -296,8 +297,10 @@ class ESPerform(object):
...
@@ -296,8 +297,10 @@ class ESPerform(object):
{
"language_type"
:{
"order"
:
"asc"
}},
{
"language_type"
:{
"order"
:
"asc"
}},
]
]
}
}
if
len
(
have_read_topic_id_list
)
>
0
:
q
[
"query"
][
"bool"
][
"must_not"
]
=
have_read_topic_id_list
result_dict
=
ESPerform
.
get_search_results
(
ESPerform
.
get_cli
(),
sub_index_name
=
"topic"
,
query_body
=
q
,
result_dict
=
ESPerform
.
get_search_results
(
ESPerform
.
get_cli
(),
sub_index_name
=
"topic"
,
query_body
=
q
,
offset
=
0
,
size
=
5000
,
routing
=
"
4,5"
)
offset
=
0
,
size
=
100
,
routing
=
"3,
4,5"
)
topic_id_list
=
[
item
[
"_source"
][
"id"
]
for
item
in
result_dict
[
"hits"
]]
topic_id_list
=
[
item
[
"_source"
][
"id"
]
for
item
in
result_dict
[
"hits"
]]
return
topic_id_list
return
topic_id_list
...
...
linucb/views/collect_data.py
View file @
e0dc1c54
...
@@ -74,8 +74,10 @@ class CollectData(object):
...
@@ -74,8 +74,10 @@ class CollectData(object):
have_read_topic_id_list
=
Tools
.
get_have_read_topic_id_list
(
device_id
,
-
1
,
TopicPageType
.
HOME_RECOMMEND
)
have_read_topic_id_list
=
Tools
.
get_have_read_topic_id_list
(
device_id
,
-
1
,
TopicPageType
.
HOME_RECOMMEND
)
recommend_topic_id_list
=
list
()
recommend_topic_id_list
=
list
()
for
index
in
range
(
0
,
100
):
tag_id_list
=
recommend_tag_list
[
0
:
100
]
recommend_topic_id_list_es
=
list
()
tag_topic_id_list
=
ESPerform
.
get_tag_topic_list
(
tag_id_list
,
have_read_topic_id_list
)
# for index in range(0,100):
# recommend_topic_id_list_es = list()
# for tag_id in recommend_tag_list[0:100]:
# for tag_id in recommend_tag_list[0:100]:
# redis_tag_id_key = self.tag_topic_id_redis_prefix + str(tag_id)
# redis_tag_id_key = self.tag_topic_id_redis_prefix + str(tag_id)
# redis_tag_id_data = redis_client.get(redis_tag_id_key)
# redis_tag_id_data = redis_client.get(redis_tag_id_key)
...
@@ -90,20 +92,19 @@ class CollectData(object):
...
@@ -90,20 +92,19 @@ class CollectData(object):
# if topic_id not in have_read_topic_id_list and topic_id not in recommend_topic_id_list_random and topic_id not in recommend_topic_id_list:
# if topic_id not in have_read_topic_id_list and topic_id not in recommend_topic_id_list_random and topic_id not in recommend_topic_id_list:
# recommend_topic_id_list_random.append(topic_id)
# recommend_topic_id_list_random.append(topic_id)
# break
# break
tag_id
=
recommend_tag_list
[
0
:
100
]
# tag_id = recommend_tag_list[0:100]
tag_topic_id_list
=
ESPerform
.
get_tag_topic_list
(
tag_id
)
# tag_topic_id_list = ESPerform.get_tag_topic_list(tag_id)
if
len
(
tag_topic_id_list
)
>
index
:
# if len(tag_topic_id_list) > index:
for
topic_id
in
tag_topic_id_list
[
index
:]:
# for topic_id in tag_topic_id_list[index:]:
if
topic_id
not
in
have_read_topic_id_list
and
topic_id
not
in
recommend_topic_id_list_es
and
topic_id
not
in
recommend_topic_id_list
:
# if topic_id not in have_read_topic_id_list and topic_id not in recommend_topic_id_list_es and topic_id not in recommend_topic_id_list:
recommend_topic_id_list_es
.
append
(
topic_id
)
# recommend_topic_id_list_es.append(topic_id)
if
len
(
recommend_topic_id_list_es
)
==
100
:
# if len(recommend_topic_id_list_es) == 100:
break
# break
# random.shuffle(recommend_topic_id_list_random)
# # random.shuffle(recommend_topic_id_list_random)
recommend_topic_id_list
.
extend
(
recommend_topic_id_list_es
)
# recommend_topic_id_list.extend(recommend_topic_id_list_es)
topic_recommend_redis_key
=
self
.
linucb_recommend_topic_id_prefix
+
str
(
device_id
)
topic_recommend_redis_key
=
self
.
linucb_recommend_topic_id_prefix
+
str
(
device_id
)
redis_data_dict
=
{
redis_data_dict
=
{
"data"
:
json
.
dumps
(
recommend
_topic_id_list
),
"data"
:
json
.
dumps
(
tag
_topic_id_list
),
"cursor"
:
0
"cursor"
:
0
}
}
redis_client
.
hmset
(
topic_recommend_redis_key
,
redis_data_dict
)
redis_client
.
hmset
(
topic_recommend_redis_key
,
redis_data_dict
)
...
...
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