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
2131d6ec
Commit
2131d6ec
authored
Jan 15, 2020
by
lixiaofang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add
parent
3b6b6fbb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
12 deletions
+8
-12
auto_tips.py
search/utils/auto_tips.py
+8
-12
No files found.
search/utils/auto_tips.py
View file @
2131d6ec
...
...
@@ -19,7 +19,7 @@ def get_suggest_tips(query, lat, lng, offset=0, size=50):
try
:
have_read_tips_set
,
ret_list
,
result_dict
=
get_query_by_es
(
query
=
str
(
query
)
.
lower
(),
lat
=
lat
,
lng
=
lng
,
offset
=
offset
,
size
=
size
)
size
=
size
,
highlight_query
=
query
)
if
len
(
ret_list
)
>=
50
:
return
ret_list
...
...
@@ -84,9 +84,10 @@ def get_suggest_tips(query, lat, lng, offset=0, size=50):
str_query
=
''
for
item
in
ss
:
str_query
+=
str
(
item
)
have_read_tips_set
,
ret_list
,
result_dict
=
get_query_by_es
(
query
=
str_query
,
lat
=
lat
,
lng
=
lng
,
offset
=
offset
,
size
=
size
)
size
=
size
,
highlight_query
=
query
)
logging
.
info
(
"get ret_list:
%
s"
%
ret_list
)
return
ret_list
...
...
@@ -103,26 +104,19 @@ def set_highlihgt(query=None, ori_name=None):
query2
=
ori_name
for
item
in
range
(
0
,
len
(
query
)):
all_word
.
add
(
query
[
item
])
for
item
in
all_word
:
is_find
=
query2
.
find
(
item
)
high_query
=
None
if
is_find
>=
0
:
highlight_marks
=
u'<>
%
s</>'
%
item
high_query
=
query2
.
replace
(
item
,
highlight_marks
)
query2
=
high_query
if
high_query
==
None
:
highlight_name
=
query2
else
:
highlight_name
=
high_query
highlight_name
=
query2
.
replace
(
'<>'
,
'<ems>'
)
.
replace
(
'</>'
,
'</ems>'
)
highlight_name
=
query2
.
replace
(
'<>'
,
'<ems>'
)
.
replace
(
'</>'
,
'</ems>'
)
return
highlight_name
def
get_query_by_es
(
query
=
''
,
lat
=
0
,
lng
=
0
,
size
=
0
,
offset
=
0
):
def
get_query_by_es
(
query
=
''
,
lat
=
0
,
lng
=
0
,
size
=
0
,
offset
=
0
,
highlight_query
=
None
):
try
:
query
=
query
.
replace
(
"
\u2006
"
,
''
)
...
...
@@ -158,12 +152,14 @@ def get_query_by_es(query='', lat=0, lng=0, size=0, offset=0):
for
tips_item
in
result_dict
[
"suggest"
][
"tips-suggest"
]:
for
hit_item
in
tips_item
[
"options"
]:
logging
.
info
(
"get hit_item:
%
s"
%
hit_item
)
if
hit_item
[
"_source"
][
"ori_name"
]
not
in
have_read_tips_set
:
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)
hit_item
[
"_source"
][
"highlight_name"
]
=
set_highlihgt
(
query
,
hit_item
[
"_source"
][
"ori_name"
])
hit_item
[
"_source"
][
"highlight_name"
]
=
set_highlihgt
(
highlight_query
,
hit_item
[
"_source"
][
"ori_name"
])
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
hit_item
[
"_source"
][
"ori_name"
]
in
g_hospital_pos_dict
:
...
...
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