Commit ef925a79 authored by litaolemo's avatar litaolemo

update

parent 28dd606d
...@@ -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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment