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
79ecc06d
Commit
79ecc06d
authored
May 08, 2019
by
段英荣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modify physical-search-topic
parent
779336c0
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
16 deletions
+18
-16
topic.py
search/utils/topic.py
+14
-11
topic.py
search/views/topic.py
+4
-5
No files found.
search/utils/topic.py
View file @
79ecc06d
...
@@ -10,7 +10,7 @@ from alpha_types.venus import TOPIC_SEARCH_SORT
...
@@ -10,7 +10,7 @@ from alpha_types.venus import TOPIC_SEARCH_SORT
from
libs.es
import
ESPerform
from
libs.es
import
ESPerform
from
.common
import
TopicDocumentField
from
.common
import
TopicDocumentField
from
search.utils.common
import
*
from
search.utils.common
import
*
from
trans2es.models.pictorial
import
PictorialTopics
class
TopicUtils
(
object
):
class
TopicUtils
(
object
):
...
@@ -860,7 +860,7 @@ class TopicUtils(object):
...
@@ -860,7 +860,7 @@ class TopicUtils(object):
@classmethod
@classmethod
def
list_topic_ids
(
cls
,
filters
,
nfilters
,
sorts_by
,
offset
=
0
,
size
=
10
,
index_name
=
"topic"
,
filter_online
=
True
):
def
list_topic_ids
(
cls
,
filters
,
nfilters
,
sorts_by
,
offset
=
0
,
size
=
10
,
index_name
=
"topic"
,
filter_online
=
True
):
try
:
must
=
cls
.
process_filters
(
filters
,
filter_online
=
filter_online
)
must
=
cls
.
process_filters
(
filters
,
filter_online
=
filter_online
)
q
=
{
q
=
{
"query"
:
{
"query"
:
{
...
@@ -876,22 +876,25 @@ class TopicUtils(object):
...
@@ -876,22 +876,25 @@ class TopicUtils(object):
if
sorts
:
if
sorts
:
q
[
"sort"
]
=
sorts
q
[
"sort"
]
=
sorts
try
:
result_dict
=
ESPerform
.
get_search_results
(
result_dict
=
ESPerform
.
get_search_results
(
ESPerform
.
get_cli
(),
sub_index_name
=
index_name
,
ESPerform
.
get_cli
(),
sub_index_name
=
index_name
,
query_body
=
q
,
offset
=
offset
,
size
=
size
query_body
=
q
,
offset
=
offset
,
size
=
size
)
)
return
{
if
len
(
result_dict
[
"hits"
])
>
0
:
"hits"
:
result_dict
[
"hits"
],
topic_id_list
=
[
item
[
"_source"
][
"id"
]
for
item
in
result_dict
[
"hits"
]]
"total_count"
:
result_dict
[
"total_count"
]
}
return
(
topic_id_list
,
result_dict
[
"total_count"
])
elif
offset
==
0
and
"pictorial_id"
in
filters
:
# 防止帖子同步延迟,画报详情页为空
pictorial_id
=
int
(
filters
[
"pictorial_id"
])
topic_id_list
=
list
(
PictorialTopics
.
objects
.
filter
(
pictorial_id
=
pictorial_id
,
is_online
=
True
,
is_deleted
=
False
)
.
values_list
(
"topic_id"
,
flat
=
True
)[
offset
:
size
])
return
(
topic_id_list
,
len
(
topic_id_list
))
else
:
return
([],
0
)
except
:
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
{
return
([],
0
)
"hits"
:
[],
"total_count"
:
0
}
@classmethod
@classmethod
def
business_topic_ids
(
cls
,
filters
,
nfilters
,
sorts_by
,
offset
=
0
,
size
=
10
,
index_name
=
"topic"
,
filter_online
=
True
):
def
business_topic_ids
(
cls
,
filters
,
nfilters
,
sorts_by
,
offset
=
0
,
size
=
10
,
index_name
=
"topic"
,
filter_online
=
True
):
...
...
search/views/topic.py
View file @
79ecc06d
...
@@ -398,13 +398,12 @@ def topic_search(filters, nfilters=None, sorts_by=None, offset=0, size=10):
...
@@ -398,13 +398,12 @@ def topic_search(filters, nfilters=None, sorts_by=None, offset=0, size=10):
"""帖子搜索。"""
"""帖子搜索。"""
try
:
try
:
result_list
=
TopicUtils
.
list_topic_ids
(
filters
=
filters
,
nfilters
=
nfilters
,
(
topic_id_list
,
total_count
)
=
TopicUtils
.
list_topic_ids
(
filters
=
filters
,
nfilters
=
nfilters
,
sorts_by
=
sorts_by
,
offset
=
offset
,
size
=
size
)
sorts_by
=
sorts_by
,
offset
=
offset
,
size
=
size
)
logging
.
info
(
"get result_list:
%
s"
%
result_list
)
topic_ids
=
[
item
[
"_source"
][
"id"
]
for
item
in
result_list
[
"hits"
]]
return
{
return
{
"topic_ids"
:
topic_id
s
,
"topic_ids"
:
topic_id
_list
,
"total_count"
:
result_list
[
"total_count"
]
"total_count"
:
total_count
}
}
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