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
b79f2e6f
Commit
b79f2e6f
authored
Dec 24, 2019
by
lixiaofang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
高亮
parent
2f6c7c4c
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
1 deletion
+31
-1
auto_tips.py
search/utils/auto_tips.py
+31
-1
No files found.
search/utils/auto_tips.py
View file @
b79f2e6f
...
@@ -172,7 +172,7 @@ def get_suggest_tips(query, lat, lng, offset=0, size=50):
...
@@ -172,7 +172,7 @@ def get_suggest_tips(query, lat, lng, offset=0, size=50):
QUERY_KEY
=
"query:search_tip"
QUERY_KEY
=
"query:search_tip"
query_base64
=
base64
.
b64encode
(
query
.
encode
(
'utf8'
))
.
decode
(
'utf8'
)
query_base64
=
base64
.
b64encode
(
query
.
encode
(
'utf8'
))
.
decode
(
'utf8'
)
if
redis_client
.
hget
(
QUERY_KEY
,
query_base64
)
is
not
None
:
if
redis_client
.
hget
(
QUERY_KEY
,
query_base64
)
is
not
None
:
value_data
=
json
.
loads
(
str
(
redis_client
.
hget
(
QUERY_KEY
,
query_base64
),
encoding
=
'utf-8'
))
value_data
=
json
.
loads
(
str
(
redis_client
.
hget
(
QUERY_KEY
,
query_base64
),
encoding
=
'utf-8'
))
if
len
(
value_data
)
>
0
:
if
len
(
value_data
)
>
0
:
for
i
in
value_data
:
for
i
in
value_data
:
...
@@ -192,13 +192,43 @@ def get_suggest_tips(query, lat, lng, offset=0, size=50):
...
@@ -192,13 +192,43 @@ def get_suggest_tips(query, lat, lng, offset=0, size=50):
"type_flag"
:
get_tips_word_type
(
ori_name
),
"highlight_name"
:
highlight_name
,
"type_flag"
:
get_tips_word_type
(
ori_name
),
"highlight_name"
:
highlight_name
,
"describe"
:
describe
})
"describe"
:
describe
})
else
:
else
:
wordresemble_ret_list
.
append
(
wordresemble_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
,
"offline_score"
:
0
,
"offline_score"
:
0
,
"type_flag"
:
get_tips_word_type
(
ori_name
),
"highlight_name"
:
highlight_name
,
"type_flag"
:
get_tips_word_type
(
ori_name
),
"highlight_name"
:
highlight_name
,
"describe"
:
describe
})
"describe"
:
describe
})
ret_list
.
extend
(
query_ret_list
)
ret_list
.
extend
(
query_ret_list
)
ret_list
.
extend
(
wordresemble_ret_list
)
ret_list
.
extend
(
wordresemble_ret_list
)
###高亮调整
query_ret_list
.
extend
(
wordresemble_ret_list
)
high_query
=
None
for
ret
in
query_ret_list
:
query2
=
ret
[
"ori_name"
]
for
item
in
range
(
0
,
len
(
query
)):
is_find
=
query2
.
find
(
query
[
item
])
if
is_find
>=
0
:
highlight_marks
=
u'<ems>
%
s</ems>'
%
query
[
item
]
high_query
=
query2
.
replace
(
query
[
item
],
highlight_marks
)
query2
=
high_query
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
:
if
len
(
ret_list
)
>=
50
:
return
ret_list
[
0
:
50
]
return
ret_list
[
0
:
50
]
else
:
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