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
0d146c99
Commit
0d146c99
authored
Jul 03, 2019
by
lixiaofang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add
parent
98863dec
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
33 deletions
+15
-33
auto_tips.py
associate/search/utils/auto_tips.py
+11
-32
es.py
libs/es.py
+4
-1
No files found.
associate/search/utils/auto_tips.py
View file @
0d146c99
...
...
@@ -51,44 +51,23 @@ def get_suggest_tips(query, agile_tag_type):
result_dict
=
ESPerform
.
get_search_results
(
ESPerform
.
get_cli
(),
sub_index_name
=
index_name
,
query_body
=
q
,
offset
=
0
,
size
=
50
,
is_suggest_request
=
True
)
agile_type_id
=
set
()
logging
.
info
(
"get agile_tag_type:
%
s"
%
agile_tag_type
)
if
agile_tag_type
>
0
:
q
=
{
"query"
:
{
"term"
:
{
"agile_tag_type"
:
agile_tag_type
}
}
}
result_dicts
=
ESPerform
.
get_search_results
(
ESPerform
.
get_cli
(),
sub_index_name
=
"associate_tag"
,
query_body
=
q
,
offset
=
0
,
size
=
100
,
is_suggest_request
=
True
)
logging
.
info
(
"get result_dict_type:
%
s"
%
result_dicts
)
for
tips_item
in
result_dicts
[
"hits"
][
"hits"
]:
agile_type_id
.
add
(
tips_item
[
"_source"
][
"agile_tag_id"
])
logging
.
info
(
"get agile_type_id:
%
s"
%
agile_type_id
)
# 获取这个类型
logging
.
info
(
"get result_dict:
%
s"
%
result_dict
)
logging
.
info
(
"get agile_tag_type:
%
s"
%
result_dict
)
for
tips_item
in
result_dict
[
"suggest"
][
"tips-suggest"
]:
for
hit_item
in
tips_item
[
"options"
]:
if
hit_item
[
"_source"
][
"ori_name"
]
not
in
have_read_tips_set
:
agile_tag_id
=
hit_item
[
"_source"
][
"agile_tag_id"
]
if
agile_tag_id
in
agile_type_id
:
have_read_tips_set
.
add
(
hit_item
[
"_source"
][
"ori_name"
])
highlight_marks
=
u'<ems>
%
s</ems>'
%
query
hit_item
[
"_source"
][
"highlight_name"
]
=
hit_item
[
"_source"
][
"ori_name"
]
.
replace
(
query
,
highlight_marks
)
ori_name
=
hit_item
[
"_source"
][
"ori_name"
]
results_num
=
hit_item
[
"_source"
][
"results_num"
]
highlight_name
=
hit_item
[
"_source"
][
"highlight_name"
]
have_read_tips_set
.
add
(
hit_item
[
"_source"
][
"ori_name"
])
highlight_marks
=
u'<ems>
%
s</ems>'
%
query
hit_item
[
"_source"
][
"highlight_name"
]
=
hit_item
[
"_source"
][
"ori_name"
]
.
replace
(
query
,
highlight_marks
)
ori_name
=
hit_item
[
"_source"
][
"ori_name"
]
results_num
=
hit_item
[
"_source"
][
"results_num"
]
highlight_name
=
hit_item
[
"_source"
][
"highlight_name"
]
ret_list
.
append
(
[{
"ori_name"
:
ori_name
,
"results_num"
:
results_num
,
"highlight"
:
highlight_name
}])
ret_list
.
append
(
[{
"ori_name"
:
ori_name
,
"results_num"
:
results_num
,
"highlight"
:
highlight_name
}])
return
ret_list
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
list
()
libs/es.py
View file @
0d146c99
...
...
@@ -57,7 +57,9 @@ class ESPerform(object):
mapping_file_path
=
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'..'
,
'trans2es'
,
'mapping'
,
'
%
s.json'
%
(
doc_type
,))
if
doc_type
==
"associate_tag"
:
if
doc_type
==
"associate_tag"
or
doc_type
==
"associate_tag_brand"
or
doc_type
==
"associate_tag_doctor"
\
or
doc_type
==
"associate_tag_instrument"
or
doc_type
==
"associate_tag_hospital"
or
doc_type
==
"associate_tag_project"
\
or
doc_type
==
"associate_tag_position"
:
mapping_file_path
=
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'..'
,
'associate'
,
'mapping'
,
'
%
s.json'
%
(
doc_type
,))
...
...
@@ -191,6 +193,7 @@ class ESPerform(object):
cls
.
put_index_mapping
(
es_cli
,
sub_index_name
)
logging
.
info
(
"duan add,query_body:
%
s"
%
str
(
query_body
)
.
encode
(
"utf-8"
))
logging
.
info
(
"duan add official_index_name :
%
s"
%
official_index_name
)
if
not
batch_search
:
res
=
es_cli
.
search
(
index
=
official_index_name
,
doc_type
=
doc_type
,
body
=
query_body
,
from_
=
offset
,
...
...
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