Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
M
meta_base_code
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
宋柯
meta_base_code
Commits
ace65e2a
Commit
ace65e2a
authored
Sep 14, 2020
by
litaolemo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
069679c8
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
3 deletions
+5
-3
func_from_es_get_article.py
utils/func_from_es_get_article.py
+5
-3
No files found.
utils/func_from_es_get_article.py
View file @
ace65e2a
...
@@ -16,8 +16,6 @@ es = Elasticsearch([
...
@@ -16,8 +16,6 @@ es = Elasticsearch([
def
get_device_num_from_es
(
word
):
def
get_device_num_from_es
(
word
):
if
word
in
exists_es_dic
:
return
exists_es_dic
[
word
]
results
=
es
.
search
(
results
=
es
.
search
(
index
=
'gm-dbmw-device'
,
index
=
'gm-dbmw-device'
,
...
@@ -162,13 +160,13 @@ def get_device_num_from_es(word):
...
@@ -162,13 +160,13 @@ def get_device_num_from_es(word):
}
}
)
)
tractate_content_num
=
results
[
"hits"
][
"total"
]
tractate_content_num
=
results
[
"hits"
][
"total"
]
exists_es_dic
[
word
]
=
tractate_content_num
return
tractate_content_num
return
tractate_content_num
def
get_es_article_num
(
tag_dict
,
allow_tag
=
[
"first_demands"
,
"second_demands"
,
"first_solutions"
,
"second_solutions"
,
def
get_es_article_num
(
tag_dict
,
allow_tag
=
[
"first_demands"
,
"second_demands"
,
"first_solutions"
,
"second_solutions"
,
"positions"
,
"second_positions"
,
"tags_v3"
]):
"positions"
,
"second_positions"
,
"tags_v3"
]):
# {tag_name:(answer_content_num, tractate_content_num, diary_content_num, total_num)}
# {tag_name:(answer_content_num, tractate_content_num, diary_content_num, total_num)}
article_dict
=
{
article_dict
=
{
"first_demands"
:
[],
"first_demands"
:
[],
"second_demands"
:
[],
"second_demands"
:
[],
...
@@ -184,6 +182,9 @@ def get_es_article_num(tag_dict, allow_tag=["first_demands", "second_demands", "
...
@@ -184,6 +182,9 @@ def get_es_article_num(tag_dict, allow_tag=["first_demands", "second_demands", "
for
tag_type
in
tag_dict
:
for
tag_type
in
tag_dict
:
for
tag_name
in
tag_dict
[
tag_type
]:
for
tag_name
in
tag_dict
[
tag_type
]:
if
tag_name
in
exists_es_dic
:
article_dict
[
tag_type
]
.
append
(
exists_es_dic
[
tag_name
])
continue
body
=
{
body
=
{
"query"
:
{
"query"
:
{
"bool"
:
{
"bool"
:
{
...
@@ -286,6 +287,7 @@ def get_es_article_num(tag_dict, allow_tag=["first_demands", "second_demands", "
...
@@ -286,6 +287,7 @@ def get_es_article_num(tag_dict, allow_tag=["first_demands", "second_demands", "
total_num
=
answer_content_num
+
tractate_content_num
+
diary_content_num
total_num
=
answer_content_num
+
tractate_content_num
+
diary_content_num
data_dic
=
{
tag_name
:
(
answer_content_num
,
tractate_content_num
,
diary_content_num
,
total_num
)}
data_dic
=
{
tag_name
:
(
answer_content_num
,
tractate_content_num
,
diary_content_num
,
total_num
)}
# print(data_dic)
# print(data_dic)
exists_es_dic
[
tag_name
]
=
data_dic
article_dict
[
tag_type
]
.
append
(
data_dic
)
article_dict
[
tag_type
]
.
append
(
data_dic
)
return
article_dict
return
article_dict
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