Commit cc3dc3ab authored by litaolemo's avatar litaolemo

update

parent 187154b5
...@@ -57,7 +57,7 @@ def user_portrait_scan_info(): ...@@ -57,7 +57,7 @@ def user_portrait_scan_info():
# user_portrait_get_empty_candidates(device_id) # user_portrait_get_empty_candidates(device_id)
try: try:
res_dic = get_user_portrait_tag3_from_redis(device_id) res_dic = get_user_portrait_tag3_from_redis(device_id)
print(res_dic) # print(res_dic)
for data_type in res_dic: for data_type in res_dic:
for tag in res_dic[data_type]: for tag in res_dic[data_type]:
if return_dict.get(tag): if return_dict.get(tag):
...@@ -161,139 +161,14 @@ def get_device_num_from_es(word): ...@@ -161,139 +161,14 @@ def get_device_num_from_es(word):
doc_type='doc', doc_type='doc',
timeout='10s', timeout='10s',
size=0, size=0,
body={ body={"aggs": {
"query": { "NAME": {
"bool": { "nested": {"path": "projects"}, "aggs": {
"should": [ "NAME1": {
{ "terms": {"field": "projects.name", "size": 10000}
"nested": {
"path": "first_demands",
"query": {
"bool": {
"must": [
{
"terms": {
"first_demands.name": [
word
]
}
}
]
}
}
}
},
{
"nested": {
"path": "second_demands",
"query": {
"bool": {
"must": [
{
"terms": {
"second_demands.name": [
word
]
}
}
]
}
}
}
},
{
"nested": {
"path": "first_solutions",
"query": {
"bool": {
"must": [
{
"terms": {
"first_solutions.name": [
word
]
}
}
]
}
}
}
},
{
"nested": {
"path": "second_solutions",
"query": {
"bool": {
"must": [
{
"terms": {
"second_solutions.name": [
word
]
}
}
]
}
}
}
},
{
"nested": {
"path": "first_positions",
"query": {
"bool": {
"must": [
{
"terms": {
"first_positions.name": [
word
]
}
}
]
}
}
}
},
{
"nested": {
"path": "second_positions",
"query": {
"bool": {
"must": [
{
"terms": {
"second_positions.name": [
word
]
}
}
]
}
}
}
},
{
"nested": {
"path": "projects",
"query": {
"bool": {
"must": [
{
"terms": {
"projects.name": [
word
]
}
}
]
}
}
} }
} }
],
"minimum_should_match": 1
} }
} }
} }
...@@ -315,6 +190,12 @@ def get_es_article_num(tag_dict): ...@@ -315,6 +190,12 @@ def get_es_article_num(tag_dict):
} }
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_type == "projects":
temp_name = "tags_v3"
elif tag_type == "first_positions":
temp_name = "positions"
else:
temp_name = tag_name
body = { body = {
"query": { "query": {
"bool": { "bool": {
...@@ -340,7 +221,7 @@ def get_es_article_num(tag_dict): ...@@ -340,7 +221,7 @@ def get_es_article_num(tag_dict):
} }
} }
} }
body["query"]["bool"]["must"].append({"term": {tag_type: tag_name}}) body["query"]["bool"]["must"].append({"term": {temp_name: tag_name}})
try: try:
results = es.search( results = es.search(
index='gm-dbmw-answer-read', index='gm-dbmw-answer-read',
...@@ -365,7 +246,7 @@ def get_es_article_num(tag_dict): ...@@ -365,7 +246,7 @@ def get_es_article_num(tag_dict):
} }
} }
} }
body["query"]["bool"]["must"].append({"term": {tag_type: tag_name}}) body["query"]["bool"]["must"].append({"term": {temp_name: tag_name}})
# tractate # tractate
try: try:
results = es.search( results = es.search(
...@@ -409,7 +290,7 @@ def get_es_article_num(tag_dict): ...@@ -409,7 +290,7 @@ def get_es_article_num(tag_dict):
} }
}, },
} }
body["query"]["bool"]["must"].append({"term": {tag_type: tag_name}}) body["query"]["bool"]["must"].append({"term": {temp_name: tag_name}})
###diary 日记 ###diary 日记
try: try:
results = es.search( results = es.search(
......
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