Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
search_tips
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
rank
search_tips
Commits
0008e9b1
Commit
0008e9b1
authored
May 06, 2020
by
lixiaofang
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into change
parents
fdd4f102
704ff3a2
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
71 additions
and
3 deletions
+71
-3
tag_transfer.py
trans2es/utils/tag_transfer.py
+71
-3
No files found.
trans2es/utils/tag_transfer.py
View file @
0008e9b1
...
...
@@ -70,23 +70,91 @@ class TagTransfer(object):
sub_index_name
=
"service"
,
doc_type
=
"service"
,
query_body
=
q
,
offset
=
0
,
size
=
0
)
doctor_results
=
result_dict
[
"total_count"
]
service_results
=
result_dict
[
"total_count"
]
if
service_results
==
0
:
service_results
=
cls
.
get_content_results_to_redis
(
instance
=
instance
)
redis_data
=
redis_client
.
hget
(
cls
.
tips_num_redis_key_prefix
,
tag_name
)
redis_val_dict
=
json
.
loads
(
str
(
redis_data
,
encoding
=
"utf-8"
))
if
redis_data
else
{}
total_count
=
doctor
_results
total_count
=
service
_results
if
't'
in
redis_val_dict
:
total_count
+=
int
(
redis_val_dict
[
't'
])
redis_val_dict
[
't'
]
=
total_count
redis_val_dict
[
's'
]
=
doctor
_results
redis_val_dict
[
's'
]
=
service
_results
redis_client
.
hset
(
cls
.
tips_num_redis_key_prefix
,
tag_name
,
json
.
dumps
(
redis_val_dict
))
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
@classmethod
def
get_content_results_to_redis
(
cls
,
instance
):
try
:
word
=
instance
.
name
.
strip
()
answer_query
=
{
"query"
:
{
"bool"
:
{
"minimum_should_match"
:
1
,
"should"
:
[{
"match_phrase"
:
{
"title"
:
{
"query"
:
word
,
"analyzer"
:
"gm_default_index"
}}},
{
"match_phrase"
:
{
"desc"
:
{
"query"
:
word
,
"analyzer"
:
"gm_default_index"
}}},
{
"match_phrase"
:
{
"answer"
:
{
"query"
:
word
,
"analyzer"
:
"gm_default_index"
}}}],
"must"
:
[{
"term"
:
{
"is_online"
:
True
}}]
}
}
}
answer_result_dict
=
ESPerform
.
get_search_results
(
ESPerform
.
get_cli
(
settings
.
GM_ORI_ES_INFO_LIST
),
sub_index_name
=
"answer"
,
doc_type
=
"answer"
,
query_body
=
answer_query
,
offset
=
0
,
size
=
0
)
answer_results
=
answer_result_dict
[
"total_count"
]
tractate_query
=
{
"query"
:
{
"bool"
:
{
"minimum_should_match"
:
1
,
"should"
:
[{
"match_phrase"
:
{
"content"
:
{
"query"
:
word
,
"analyzer"
:
"gm_default_index"
}}},
{
"match_phrase"
:
{
"tractate_tag_name"
:
{
"query"
:
word
,
"analyzer"
:
"gm_default_index"
}}},
{
"match_phrase"
:
{
"tractate_tag_name_content"
:
{
"query"
:
word
,
"analyzer"
:
"gm_default_index"
}}}],
"must"
:
[{
"term"
:
{
"is_online"
:
True
}}]
}
}
}
tractate_result_dict
=
ESPerform
.
get_search_results
(
ESPerform
.
get_cli
(
settings
.
GM_ORI_ES_INFO_LIST
),
sub_index_name
=
"tractate"
,
doc_type
=
"tractate"
,
query_body
=
tractate_query
,
offset
=
0
,
size
=
0
)
tractate_results
=
tractate_result_dict
[
"total_count"
]
diary_query
=
{
"query"
:
{
"bool"
:
{
"minimum_should_match"
:
1
,
"should"
:
[{
"match_phrase"
:
{
"tags"
:
{
"query"
:
word
,
"analyzer"
:
"gm_default_index"
}}},
{
"match_phrase"
:
{
"answer"
:
{
"query"
:
word
,
"analyzer"
:
"gm_default_index"
}}},
{
"match_phrase"
:
{
"service.name"
:
{
"query"
:
word
,
"analyzer"
:
"gm_default_index"
}}}],
"must"
:
[{
"term"
:
{
"is_online"
:
True
}},
{
"range"
:
{
"content_level"
:
{
"gte"
:
"3"
}}}]
}
},
}
diary_result_dict
=
ESPerform
.
get_search_results
(
ESPerform
.
get_cli
(
settings
.
GM_ORI_ES_INFO_LIST
),
sub_index_name
=
"diary"
,
doc_type
=
"diary"
,
query_body
=
diary_query
,
offset
=
0
,
size
=
0
)
diary_results
=
diary_result_dict
[
"total_count"
]
total_count
=
int
(
answer_results
)
+
int
(
tractate_results
)
+
int
(
diary_results
)
logging
.
info
(
"get content_info:
%
s"
%
total_count
)
return
total_count
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
0
@classmethod
def
get_tag_suggest_data_list
(
cls
,
instance
):
try
:
...
...
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