Commit ef925a79 authored by litaolemo's avatar litaolemo

update

parent 28dd606d
......@@ -5,6 +5,7 @@
# @author : litao
import pymysql
from elasticsearch import Elasticsearch
exists_es_dic = {}
es = Elasticsearch([
{
......@@ -15,6 +16,7 @@ es = Elasticsearch([
'port': 9200,
}])
def con_sql_jerry_prod(sql):
# 从数据库的表里获取数据
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):
db.close()
return result
def con_sql_doris_prod(sql):
# 从数据库的表里获取数据
db = pymysql.connect(host='172.16.30.136', port=3306, user='doris', passwd='o5gbA27hXHHm',
......@@ -37,7 +40,6 @@ def con_sql_doris_prod(sql):
def get_device_num_from_es(word):
results = es.search(
index='gm-dbmw-device',
doc_type='doc',
......@@ -183,27 +185,31 @@ def get_device_num_from_es(word):
tractate_content_num = results["hits"]["total"]
return tractate_content_num
def get_tractate_tags_from_es(doc_id):
body = {
"query":{
"bool":{
"filter":[
{"term":{"_id":doc_id}}
"query": {
"bool": {
"filter": [
{"term": {"_id": doc_id}}
]
}
}
}
# tractate
results = es.get(
index='gm-dbmw-answer-read',
doc_type='answer',
results = es.search(
index='gm-dbmw-tractate-read',
doc_type='tractate',
timeout='10s',
body=body
)
print(results)
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 = {
"first_demands": [],
"second_demands": [],
......@@ -329,6 +335,7 @@ def get_es_article_num(tag_dict, allow_tag=["first_demands", "second_demands", "
return article_dict
def get_user_post_from_mysql():
data_tag_count = {}
second_demands_count_dict = {}
......@@ -349,4 +356,4 @@ def get_user_post_from_mysql():
tags_v3_count_dict[tag] += 1
else:
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