Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
M
mentha
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
1
Merge Requests
1
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
rank
mentha
Commits
3ffa9f31
Commit
3ffa9f31
authored
Nov 19, 2020
by
李小芳
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add
parent
55e3273d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
1 deletion
+32
-1
toutiao.py
qa/models/toutiao.py
+32
-1
No files found.
qa/models/toutiao.py
View file @
3ffa9f31
...
...
@@ -69,6 +69,17 @@ def get_es(es_hosts_config=None):
return
new_es
def
get_service_es
(
es_hosts_config
=
None
):
init_args
=
{
'sniff_on_start'
:
False
,
'sniff_on_connection_fail'
:
False
,
}
new_hosts
=
settings
.
ES7_HOSTS_SERVICE
if
not
es_hosts_config
else
es_hosts_config
new_es
=
Es
(
hosts
=
new_hosts
,
**
init_args
)
return
new_es
def
es_index_adapt
(
index_prefix
,
doc_type
,
rw
=
None
):
"""get the adapted index name
"""
...
...
@@ -99,6 +110,26 @@ def es_query(doc, body, offset, size, es=None):
return
res
def
es_query_service
(
doc
,
body
,
offset
,
size
,
es
=
None
):
if
es
is
None
:
es
=
get_service_es
()
index
=
es_index_adapt
(
index_prefix
=
settings
.
ES7_HOSTS_SERVICE
,
doc_type
=
doc
,
rw
=
'read'
)
res
=
es
.
search
(
index
=
index
,
doc_type
=
doc
,
timeout
=
settings
.
ES7_HOSTS_SERVICE
,
body
=
body
,
from_
=
offset
,
size
=
size
)
return
res
def
has_service
(
tag_list
,
content_keyword
):
q
=
dict
()
q
[
"query"
]
=
{
"bool"
:
...
...
@@ -111,7 +142,7 @@ def has_service(tag_list, content_keyword):
{
"terms"
:
{
"closure_tags"
:
content_keyword
}}],
"minimum_should_match"
:
1
}}
res
=
es_query
(
doc
=
"service"
,
body
=
q
,
offset
=
0
,
size
=
1
)
res
=
es_query
_service
(
doc
=
"service"
,
body
=
q
,
offset
=
0
,
size
=
1
)
if
res
:
if
res
[
'hits'
][
'total'
]
>
0
:
return
True
...
...
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