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
7f3ab355
Commit
7f3ab355
authored
Dec 27, 2019
by
lixiaofang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
高亮
parent
1c737530
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
22 deletions
+25
-22
auto_tips.py
search/utils/auto_tips.py
+25
-22
No files found.
search/utils/auto_tips.py
View file @
7f3ab355
...
@@ -125,8 +125,9 @@ def get_suggest_tips(query, lat, lng, offset=0, size=50):
...
@@ -125,8 +125,9 @@ def get_suggest_tips(query, lat, lng, offset=0, size=50):
if
hit_item
[
"_source"
][
"ori_name"
]
not
in
have_read_tips_set
:
if
hit_item
[
"_source"
][
"ori_name"
]
not
in
have_read_tips_set
:
have_read_tips_set
.
add
(
hit_item
[
"_source"
][
"ori_name"
])
have_read_tips_set
.
add
(
hit_item
[
"_source"
][
"ori_name"
])
highlight_marks
=
u'<ems>
%
s</ems>'
%
query
highlight_marks
=
u'<ems>
%
s</ems>'
%
query
hit_item
[
"_source"
][
"highlight_name"
]
=
hit_item
[
"_source"
][
"ori_name"
]
.
replace
(
query
,
# hit_item["_source"]["highlight_name"] = hit_item["_source"]["ori_name"].replace(query,
highlight_marks
)
# highlight_marks)
hit_item
[
"_source"
][
"highlight_name"
]
=
set_highlihgt
(
query
,
hit_item
[
"_source"
][
"ori_name"
])
if
hit_item
[
"_source"
][
"type_flag"
]
==
"hospital"
:
if
hit_item
[
"_source"
][
"type_flag"
]
==
"hospital"
:
if
lat
is
not
None
and
lng
is
not
None
and
lat
!=
0.0
and
lng
!=
0.0
:
if
lat
is
not
None
and
lng
is
not
None
and
lat
!=
0.0
and
lng
!=
0.0
:
if
hit_item
[
"_source"
][
"ori_name"
]
in
g_hospital_pos_dict
:
if
hit_item
[
"_source"
][
"ori_name"
]
in
g_hospital_pos_dict
:
...
@@ -198,7 +199,8 @@ def get_suggest_tips(query, lat, lng, offset=0, size=50):
...
@@ -198,7 +199,8 @@ def get_suggest_tips(query, lat, lng, offset=0, size=50):
describe
=
"约"
+
str
(
result_num
)
+
"个结果"
if
result_num
else
""
describe
=
"约"
+
str
(
result_num
)
+
"个结果"
if
result_num
else
""
logging
.
info
(
"get result_num:
%
s"
%
result_num
)
logging
.
info
(
"get result_num:
%
s"
%
result_num
)
highlight_marks
=
u'<ems>
%
s</ems>'
%
query
highlight_marks
=
u'<ems>
%
s</ems>'
%
query
highlight_name
=
ori_name
.
replace
(
query
,
highlight_marks
)
# highlight_name = ori_name.replace(query, highlight_marks)
highlight_name
=
set_highlihgt
(
query
,
ori_name
)
if
ori_name
==
query
:
if
ori_name
==
query
:
query_ret_list
.
append
(
query_ret_list
.
append
(
{
"results_num"
:
result_num
,
"ori_name"
:
ori_name
,
"id"
:
None
,
"is_online"
:
True
,
{
"results_num"
:
result_num
,
"ori_name"
:
ori_name
,
"id"
:
None
,
"is_online"
:
True
,
...
@@ -215,30 +217,12 @@ def get_suggest_tips(query, lat, lng, offset=0, size=50):
...
@@ -215,30 +217,12 @@ def get_suggest_tips(query, lat, lng, offset=0, size=50):
ret_list
.
extend
(
query_ret_list
)
ret_list
.
extend
(
query_ret_list
)
ret_list
.
extend
(
wordresemble_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
=
[{
'痩脸针'
:
"瘦脸针"
}]
fanti_query
=
[{
'痩脸针'
:
"瘦脸针"
}]
for
item
in
ret_list
:
for
item
in
ret_list
:
result_num
=
[[
item
[
'results_num'
],
list
(
ret
.
values
())[
0
],
list
(
ret
.
keys
())[
0
]]
for
ret
in
fanti_query
result_num
=
[[
item
[
'results_num'
],
list
(
ret
.
values
())[
0
],
list
(
ret
.
keys
())[
0
]]
for
ret
in
fanti_query
if
if
list
(
ret
.
keys
())[
0
]
==
item
[
'ori_name'
]]
list
(
ret
.
keys
())[
0
]
==
item
[
'ori_name'
]]
if
len
(
result_num
)
>
0
:
if
len
(
result_num
)
>
0
:
ret_list
.
remove
(
item
)
ret_list
.
remove
(
item
)
...
@@ -255,3 +239,22 @@ def get_suggest_tips(query, lat, lng, offset=0, size=50):
...
@@ -255,3 +239,22 @@ def get_suggest_tips(query, lat, lng, offset=0, size=50):
except
:
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
list
()
return
list
()
def
set_highlihgt
(
query
=
None
,
ori_name
=
None
):
###高亮调整
query2
=
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
:
highlight_name
=
query2
else
:
highlight_name
=
high_query
return
highlight_name
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