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
ef925a79
Commit
ef925a79
authored
Sep 17, 2020
by
litaolemo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
28dd606d
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
10 deletions
+17
-10
func_from_es_get_article.py
utils/func_from_es_get_article.py
+17
-10
No files found.
utils/func_from_es_get_article.py
View file @
ef925a79
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
# @author : litao
# @author : litao
import
pymysql
import
pymysql
from
elasticsearch
import
Elasticsearch
from
elasticsearch
import
Elasticsearch
exists_es_dic
=
{}
exists_es_dic
=
{}
es
=
Elasticsearch
([
es
=
Elasticsearch
([
{
{
...
@@ -15,6 +16,7 @@ es = Elasticsearch([
...
@@ -15,6 +16,7 @@ es = Elasticsearch([
'port'
:
9200
,
'port'
:
9200
,
}])
}])
def
con_sql_jerry_prod
(
sql
):
def
con_sql_jerry_prod
(
sql
):
# 从数据库的表里获取数据
# 从数据库的表里获取数据
db
=
pymysql
.
connect
(
host
=
'172.16.40.158'
,
port
=
4000
,
user
=
'st_user'
,
passwd
=
'aqpuBLYzEV7tML5RPsN1pntUzFy'
,
db
=
pymysql
.
connect
(
host
=
'172.16.40.158'
,
port
=
4000
,
user
=
'st_user'
,
passwd
=
'aqpuBLYzEV7tML5RPsN1pntUzFy'
,
...
@@ -25,6 +27,7 @@ def con_sql_jerry_prod(sql):
...
@@ -25,6 +27,7 @@ def con_sql_jerry_prod(sql):
db
.
close
()
db
.
close
()
return
result
return
result
def
con_sql_doris_prod
(
sql
):
def
con_sql_doris_prod
(
sql
):
# 从数据库的表里获取数据
# 从数据库的表里获取数据
db
=
pymysql
.
connect
(
host
=
'172.16.30.136'
,
port
=
3306
,
user
=
'doris'
,
passwd
=
'o5gbA27hXHHm'
,
db
=
pymysql
.
connect
(
host
=
'172.16.30.136'
,
port
=
3306
,
user
=
'doris'
,
passwd
=
'o5gbA27hXHHm'
,
...
@@ -37,7 +40,6 @@ def con_sql_doris_prod(sql):
...
@@ -37,7 +40,6 @@ def con_sql_doris_prod(sql):
def
get_device_num_from_es
(
word
):
def
get_device_num_from_es
(
word
):
results
=
es
.
search
(
results
=
es
.
search
(
index
=
'gm-dbmw-device'
,
index
=
'gm-dbmw-device'
,
doc_type
=
'doc'
,
doc_type
=
'doc'
,
...
@@ -183,27 +185,31 @@ def get_device_num_from_es(word):
...
@@ -183,27 +185,31 @@ def get_device_num_from_es(word):
tractate_content_num
=
results
[
"hits"
][
"total"
]
tractate_content_num
=
results
[
"hits"
][
"total"
]
return
tractate_content_num
return
tractate_content_num
def
get_tractate_tags_from_es
(
doc_id
):
def
get_tractate_tags_from_es
(
doc_id
):
body
=
{
body
=
{
"query"
:{
"query"
:
{
"bool"
:{
"bool"
:
{
"filter"
:[
"filter"
:
[
{
"term"
:
{
"_id"
:
doc_id
}}
{
"term"
:
{
"_id"
:
doc_id
}}
]
]
}
}
}
}
}
}
# tractate
# tractate
results
=
es
.
get
(
results
=
es
.
search
(
index
=
'gm-dbmw-
answer
-read'
,
index
=
'gm-dbmw-
tractate
-read'
,
doc_type
=
'
answer
'
,
doc_type
=
'
tractate
'
,
timeout
=
'10s'
,
timeout
=
'10s'
,
body
=
body
body
=
body
)
)
print
(
results
)
print
(
results
)
return
results
[
"hits"
][
'hits'
][
0
]
return
results
[
"hits"
][
'hits'
][
0
]
def
get_es_article_num
(
tag_dict
,
allow_tag
=
[
"first_demands"
,
"second_demands"
,
"first_solutions"
,
"second_solutions"
,
"positions"
,
"second_positions"
,
"tags_v3"
]):
def
get_es_article_num
(
tag_dict
,
allow_tag
=
[
"first_demands"
,
"second_demands"
,
"first_solutions"
,
"second_solutions"
,
"positions"
,
"second_positions"
,
"tags_v3"
]):
article_dict
=
{
article_dict
=
{
"first_demands"
:
[],
"first_demands"
:
[],
"second_demands"
:
[],
"second_demands"
:
[],
...
@@ -329,6 +335,7 @@ def get_es_article_num(tag_dict, allow_tag=["first_demands", "second_demands", "
...
@@ -329,6 +335,7 @@ def get_es_article_num(tag_dict, allow_tag=["first_demands", "second_demands", "
return
article_dict
return
article_dict
def
get_user_post_from_mysql
():
def
get_user_post_from_mysql
():
data_tag_count
=
{}
data_tag_count
=
{}
second_demands_count_dict
=
{}
second_demands_count_dict
=
{}
...
@@ -349,4 +356,4 @@ def get_user_post_from_mysql():
...
@@ -349,4 +356,4 @@ def get_user_post_from_mysql():
tags_v3_count_dict
[
tag
]
+=
1
tags_v3_count_dict
[
tag
]
+=
1
else
:
else
:
tags_v3_count_dict
[
tag
]
=
1
tags_v3_count_dict
[
tag
]
=
1
return
second_demands_count_dict
,
tags_v3_count_dict
return
second_demands_count_dict
,
tags_v3_count_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