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
1d812fa2
Commit
1d812fa2
authored
Sep 25, 2019
by
高雅喆
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'gyz' into gyz_es
parents
60ffb02d
df3e8f27
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
69 additions
and
0 deletions
+69
-0
es.py
libs/es.py
+69
-0
topic.py
search/views/topic.py
+0
-0
No files found.
libs/es.py
View file @
1d812fa2
...
...
@@ -401,6 +401,7 @@ class ESPerform(object):
{
"term"
:
{
"content_level"
:
6
}},
{
"term"
:
{
"is_online"
:
True
}},
{
"term"
:
{
"is_deleted"
:
False
}},
{
"term"
:
{
"is_new_topic"
:
False
}},
{
"terms"
:
{
"tag_list"
:
tag_id
}}
]
}
...
...
@@ -414,6 +415,15 @@ class ESPerform(object):
"include"
:
[
"id"
,
"user_id"
,
"latest_reply_time"
]
},
"sort"
:
[
{
"_script"
:
{
"order"
:
"desc"
,
"script"
:
{
"inline"
:
"doc['topic_ctr_30'].value+doc['like_rate_30'].value"
},
"type"
:
"number"
}
},
{
"latest_reply_time"
:
{
"order"
:
"desc"
}},
{
"create_time_val"
:
{
"order"
:
"desc"
}},
{
"language_type"
:
{
"order"
:
"asc"
}},
...
...
@@ -450,6 +460,65 @@ class ESPerform(object):
logging
.
info
(
"linucb_tag_id_list_2_same_tagset_ids_2_topics_detail:"
+
str
(
topic_id_dict_latest_reply_time
))
return
topic_id_list
,
topic_id_dict
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
list
(),
dict
()
@classmethod
def
get_tag_new_topic_list
(
cls
,
tag_id
,
have_read_topic_id_list
,
size
=
10
):
try
:
functions_list
=
list
()
for
id
in
tag_id
:
functions_list
.
append
(
{
"filter"
:
{
"term"
:
{
"tag_list"
:
id
}},
"weight"
:
1
}
)
q
=
{
"query"
:
{
"function_score"
:
{
"query"
:
{
"bool"
:
{
"must"
:
[
{
"term"
:
{
"content_level"
:
6
}},
{
"term"
:
{
"is_online"
:
True
}},
{
"term"
:
{
"is_deleted"
:
False
}},
{
"term"
:
{
"is_new_topic"
:
True
}},
{
"terms"
:
{
"tag_list"
:
tag_id
}}
]
}
},
"boost_mode"
:
"sum"
,
"score_mode"
:
"sum"
,
"functions"
:
functions_list
}
},
"_source"
:
{
"include"
:
[
"id"
,
"user_id"
]
},
"sort"
:
[
{
"latest_reply_time"
:
{
"order"
:
"desc"
}},
{
"create_time_val"
:
{
"order"
:
"desc"
}},
{
"language_type"
:
{
"order"
:
"asc"
}},
],
"collapse"
:
{
"field"
:
"user_id"
}
}
if
len
(
have_read_topic_id_list
)
>
0
:
q
[
"query"
][
"function_score"
][
"query"
][
"bool"
][
"must_not"
]
=
{
"terms"
:
{
"id"
:
have_read_topic_id_list
}
}
result_dict
=
ESPerform
.
get_search_results
(
ESPerform
.
get_cli
(),
sub_index_name
=
"topic-high-star"
,
query_body
=
q
,
offset
=
0
,
size
=
size
,
routing
=
"6"
)
topic_id_list
=
[
item
[
"_source"
][
"id"
]
for
item
in
result_dict
[
"hits"
]]
return
topic_id_list
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
list
()
...
...
search/views/topic.py
View file @
1d812fa2
This diff is collapsed.
Click to expand it.
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