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
728de655
Commit
728de655
authored
Mar 25, 2019
by
lixiaofang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add
parent
f3b872ab
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
72 additions
and
1 deletion
+72
-1
topic.py
search/utils/topic.py
+71
-0
business_topic.py
search/views/business_topic.py
+1
-1
No files found.
search/utils/topic.py
View file @
728de655
...
...
@@ -584,6 +584,12 @@ class TopicUtils(object):
for
k
,
v
in
filters
.
items
():
if
k
==
"is_complaint"
:
f
.
append
({
"term"
:
{
k
:
v
},
})
if
not
v
:
continue
...
...
@@ -723,3 +729,68 @@ class TopicUtils(object):
"hits"
:
[],
"total_count"
:
0
}
@classmethod
def
business_topic_ids
(
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
),
}
}
logging
.
info
(
"get query business_topic:
%
s"
%
q
)
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
}
search/views/business_topic.py
View file @
728de655
...
...
@@ -18,7 +18,7 @@ def business_topic_search(filters, nfilters=None, sorts_by=None, offset=0, size=
"""帖子搜索。"""
try
:
result_list
=
TopicUtils
.
list
_topic_ids
(
result_list
=
TopicUtils
.
business
_topic_ids
(
filters
=
filters
,
nfilters
=
nfilters
,
sorts_by
=
sorts_by
,
offset
=
offset
,
size
=
size
,
filter_online
=
False
,
index_name
=
"topic"
...
...
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