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
6e1153b6
Commit
6e1153b6
authored
May 13, 2019
by
lixiaofang
Browse files
Options
Browse Files
Download
Plain Diff
add
parents
0385d4f6
09e1e0b8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
72 deletions
+10
-72
topic.py
search/utils/topic.py
+10
-72
No files found.
search/utils/topic.py
View file @
6e1153b6
...
...
@@ -12,6 +12,7 @@ from .common import TopicDocumentField
from
search.utils.common
import
*
from
trans2es.models.pictorial
import
PictorialTopics
class
TopicUtils
(
object
):
@classmethod
...
...
@@ -897,89 +898,27 @@ class TopicUtils(object):
query_body
=
q
,
offset
=
offset
,
size
=
size
)
if
len
(
result_dict
[
"hits"
])
>
0
:
if
len
(
result_dict
[
"hits"
])
>
0
:
topic_id_list
=
[
item
[
"_source"
][
"id"
]
for
item
in
result_dict
[
"hits"
]]
return
(
topic_id_list
,
result_dict
[
"total_count"
])
elif
offset
==
0
and
"pictorial_id"
in
filters
:
# 防止帖子同步延迟,画报详情页为空
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
])
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
))
return
(
topic_id_list
,
len
(
topic_id_list
))
else
:
return
([],
0
)
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
([],
0
)
return
([],
0
)
@classmethod
def
business_topic_id
(
cls
,
filters
,
nfilters
,
sorts_by
,
offset
=
0
,
size
=
10
,
index_name
=
"topic"
,
filter_online
=
True
):
must
=
cls
.
process_filters
(
filters
,
filter_online
=
filter_online
)
query
=
''
for
k
,
v
in
filters
.
items
():
if
k
==
"content"
:
query
=
filters
[
k
]
q
=
{}
q
[
"query"
]
=
{
"function_score"
:
{
"functions"
:
[{
"filter"
:
{
"bool"
:
{
"must"
:
must
,
"must_not"
:
cls
.
process_nfilters
(
nfilters
),
}
},
"weight"
:
1
}],
"query"
:
{
"multi_match"
:
{
"fields"
:
[
"content"
],
"type"
:
"cross_fields"
,
"operator"
:
"and"
,
"query"
:
query
}
}
}
}
if
query
==
''
:
q
[
"query"
]
=
{
"bool"
:
{
"must"
:
must
,
"must_not"
:
cls
.
process_nfilters
(
nfilters
),
}
}
if
sorts_by
:
sorts
=
cls
.
process_sort
(
sorts_by
)
if
sorts
:
q
[
"sort"
]
=
sorts
try
:
result_dict
=
ESPerform
.
get_search_results
(
ESPerform
.
get_cli
(),
sub_index_name
=
index_name
,
query_body
=
q
,
offset
=
offset
,
size
=
size
)
return
{
"hits"
:
result_dict
[
"hits"
],
"total_count"
:
result_dict
[
"total_count"
]
}
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
{
"hits"
:
[],
"total_count"
:
0
}
@classmethod
def
business_topic_id
(
cls
,
filters
,
nfilters
,
sorts_by
,
offset
=
0
,
size
=
10
,
index_name
=
"topic"
,
filter_online
=
True
):
must
=
cls
.
business_filters
(
filters
,
filter_online
=
filter_online
)
q
=
{
"query"
:
{
...
...
@@ -1054,4 +993,3 @@ class TopicUtils(object):
})
return
f
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