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
1c737530
Commit
1c737530
authored
Dec 27, 2019
by
lixiaofang
Browse files
Options
Browse Files
Download
Plain Diff
sug联想词优化
parents
1209550a
65505254
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
5 deletions
+35
-5
auto_tips.py
search/utils/auto_tips.py
+35
-5
No files found.
search/utils/auto_tips.py
View file @
1c737530
...
...
@@ -114,10 +114,8 @@ def get_suggest_tips(query, lat, lng, offset=0, size=50):
get_tag_wiki_data
=
list
()
have_read_tips_set
=
set
()
ret_list
=
list
()
doctor_hospital_equal_query
=
list
()
tag_equal_query
=
list
()
result_dict
=
ESPerform
.
get_search_results
(
ESPerform
.
get_cli
(),
sub_index_name
=
"suggest"
,
query_body
=
q
,
offset
=
offset
,
size
=
size
,
is_suggest_request
=
True
)
...
...
@@ -152,11 +150,11 @@ def get_suggest_tips(query, lat, lng, offset=0, size=50):
else
:
hit_item
[
"_source"
][
"describe"
]
=
""
##在这里把完全和query词相等的数据
if
hit_item
[
"_source"
][
"ori_name"
]
==
query
:
doctor_hospital_equal_query
.
append
(
hit_item
[
"_source"
])
else
:
get_doctor_hospital_data
.
append
(
hit_item
[
"_source"
])
else
:
if
hit_item
[
"_source"
][
"type_flag"
]
==
"doctor"
:
hit_item
[
"_source"
][
"describe"
]
=
""
...
...
@@ -165,11 +163,9 @@ def get_suggest_tips(query, lat, lng, offset=0, size=50):
doctor_hospital_equal_query
.
append
(
hit_item
[
"_source"
])
else
:
get_doctor_hospital_data
.
append
(
hit_item
[
"_source"
])
else
:
hit_item
[
"_source"
][
"describe"
]
=
"约"
+
str
(
hit_item
[
"_source"
][
"results_num"
])
+
"个结果"
if
\
hit_item
[
"_source"
][
"results_num"
]
else
""
if
hit_item
[
"_source"
][
"ori_name"
]
==
query
:
tag_equal_query
.
append
(
hit_item
[
"_source"
])
else
:
...
...
@@ -210,13 +206,47 @@ def get_suggest_tips(query, lat, lng, offset=0, size=50):
"type_flag"
:
get_tips_word_type
(
ori_name
),
"highlight_name"
:
highlight_name
,
"describe"
:
describe
})
else
:
wordresemble_ret_list
.
append
(
{
"results_num"
:
result_num
,
"ori_name"
:
ori_name
,
"id"
:
None
,
"is_online"
:
True
,
"offline_score"
:
0
,
"type_flag"
:
get_tips_word_type
(
ori_name
),
"highlight_name"
:
highlight_name
,
"describe"
:
describe
})
ret_list
.
extend
(
query_ret_list
)
ret_list
.
extend
(
wordresemble_ret_list
)
###高亮调整
for
ret
in
ret_list
:
query2
=
ret
[
"ori_name"
]
for
item
in
range
(
0
,
len
(
query
)):
is_find
=
query2
.
find
(
query
[
item
])
high_query
=
None
if
is_find
>=
0
:
highlight_marks
=
u'<ems>
%
s</ems>'
%
query
[
item
]
high_query
=
query2
.
replace
(
query
[
item
],
highlight_marks
)
query2
=
high_query
if
high_query
==
None
:
ret
[
"highlight_name"
]
=
query2
else
:
ret
[
"highlight_name"
]
=
high_query
###繁体字删掉,把搜索结果加到简体字上边
fanti_query
=
[{
'痩脸针'
:
"瘦脸针"
}]
for
item
in
ret_list
:
result_num
=
[[
item
[
'results_num'
],
list
(
ret
.
values
())[
0
],
list
(
ret
.
keys
())[
0
]]
for
ret
in
fanti_query
if
list
(
ret
.
keys
())[
0
]
==
item
[
'ori_name'
]]
if
len
(
result_num
)
>
0
:
ret_list
.
remove
(
item
)
for
item
in
ret_list
:
if
item
[
'ori_name'
]
==
result_num
[
0
][
1
]:
item
[
'results_num'
]
+=
result_num
[
0
][
0
]
####
if
len
(
ret_list
)
>=
50
:
return
ret_list
[
0
:
50
]
else
:
...
...
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