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
de3543a2
Commit
de3543a2
authored
May 13, 2019
by
段英荣
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'heras' into 'master'
修改搜索逻辑 See merge request
!329
parents
ed24f39e
67188479
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
31 deletions
+49
-31
topic.py
search/utils/topic.py
+49
-31
No files found.
search/utils/topic.py
View file @
de3543a2
...
...
@@ -896,44 +896,19 @@ class TopicUtils(object):
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
([],
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"
]
=
{
must
=
cls
.
business_filters
(
filters
,
filter_online
=
filter_online
)
q
=
{
"query"
:
{
"bool"
:
{
"must"
:
must
,
"must_not"
:
cls
.
process_nfilters
(
nfilters
),
}
}
}
}
if
sorts_by
:
sorts
=
cls
.
process_sort
(
sorts_by
)
...
...
@@ -956,3 +931,46 @@ class TopicUtils(object):
"hits"
:
[],
"total_count"
:
0
}
@classmethod
def
business_filters
(
cls
,
filters
,
filter_online
=
True
):
"""处理过滤器部分。"""
logging
.
info
(
"get filters:
%
s"
%
filters
)
f
=
[
{
"term"
:
{
"is_deleted"
:
False
}},
]
if
not
filters
:
return
f
if
filter_online
:
f
.
append
({
"term"
:
{
"is_online"
:
True
}})
for
k
,
v
in
filters
.
items
():
if
v
in
(
None
,
''
,
[]):
continue
if
k
==
"content"
:
f
.
append
({
"match"
:
{
k
:
v
}
})
elif
k
==
"virtual_content_level"
:
f
.
append
({
"match"
:
{
k
:
v
}
})
else
:
if
isinstance
(
v
,
list
):
f
.
append
({
"terms"
:
{
k
:
v
},
})
else
:
f
.
append
({
"term"
:
{
k
:
v
},
})
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