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
58e44888
Commit
58e44888
authored
Aug 27, 2019
by
李小芳
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'wordres' into 'master'
Wordres See merge request
!28
parents
0db0bc46
9653ed9f
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
42 additions
and
20 deletions
+42
-20
words_utils.py
associate/commons/words_utils.py
+2
-0
auto_tips.py
search/utils/auto_tips.py
+36
-15
__init__.pyc
search_tips/__init__.pyc
+0
-0
productwiki_transfer.py
trans2es/utils/productwiki_transfer.py
+4
-5
No files found.
associate/commons/words_utils.py
View file @
58e44888
...
...
@@ -100,6 +100,8 @@ class QueryWordAttr(object):
key
=
cls
.
tips_num_redis_key_prefix
+
str
(
id
)
results_num
=
redis_client
.
get
(
key
)
# results_num = json.loads(str(redis_data, encoding="utf-8")) if redis_data else {}
if
results_num
==
None
:
results_num
=
0
return
int
(
results_num
)
except
:
...
...
search/utils/auto_tips.py
View file @
58e44888
...
...
@@ -165,28 +165,49 @@ def get_suggest_tips(query, lat, lng, offset=0, size=50):
ret_list
.
extend
(
get_tag_wiki_data
)
ret_list
.
extend
(
get_doctor_hospital_data
)
logging
.
info
(
"get have_read_tips_set:
%
s"
%
have_read_tips_set
)
if
len
(
result_dict
[
"suggest"
][
"tips-suggest"
])
>=
50
:
return
ret_list
else
:
QUERY_KEY
=
"query:{}:search_tip"
query_ret_list
=
[]
wordresemble_ret_list
=
[]
value_data
=
[]
QUERY_KEY
=
"query:search_tip"
query_base64
=
base64
.
b64encode
(
query
.
encode
(
'utf8'
))
.
decode
(
'utf8'
)
key
=
QUERY_KEY
.
format
(
query_base64
)
labels
=
list
(
map
(
lambda
x
:
x
.
decode
(
"utf8"
),
list
(
redis_client
.
smembers
(
key
))))
for
i
in
labels
:
ori
=
i
.
split
(
":"
)[
0
]
ori_name
=
base64
.
b64decode
(
ori
.
encode
(
'utf8'
))
.
decode
(
'utf8'
)
if
ori_name
not
in
have_read_tips_set
:
have_read_tips_set
.
add
(
ori_name
)
result_num
=
i
.
split
(
":"
)[
1
]
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"
:
ori_name
,
"describe"
:
""
})
if
redis_client
.
hget
(
QUERY_KEY
,
query_base64
)
is
not
None
:
value_data
=
json
.
loads
(
redis_client
.
hget
(
QUERY_KEY
,
query_base64
))
logging
.
info
(
"get value_data:
%
s"
%
value_data
)
if
len
(
value_data
)
>
0
:
for
i
in
value_data
:
key
=
list
(
i
.
keys
())[
0
]
ori_name
=
str
(
base64
.
b64decode
(
key
),
"utf-8"
)
if
ori_name
not
in
have_read_tips_set
:
have_read_tips_set
.
add
(
ori_name
)
result_num
=
i
.
get
(
key
,
0
)
describe
=
"约"
+
str
(
result_num
)
+
"个结果"
if
result_num
else
""
logging
.
info
(
"get result_num:
%
s"
%
result_num
)
highlight_marks
=
u'<ems>
%
s</ems>'
%
query
highlight_name
=
ori_name
.
replace
(
query
,
highlight_marks
)
if
ori_name
==
query
:
query_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
})
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
})
logging
.
info
(
"get query_ret_list:
%
s"
%
query_ret_list
)
logging
.
info
(
"get wordresemble_ret_list:
%
s"
%
wordresemble_ret_list
)
ret_list
.
extend
(
query_ret_list
)
ret_list
.
extend
(
wordresemble_ret_list
)
if
len
(
ret_list
)
>=
50
:
return
ret_list
[
0
:
50
]
else
:
return
ret_list
...
...
search_tips/__init__.pyc
View file @
58e44888
No preview for this file type
trans2es/utils/productwiki_transfer.py
View file @
58e44888
...
...
@@ -4,13 +4,13 @@ import os
import
sys
import
logging
import
traceback
from
libs.tools
import
tzlc
,
getMd5Digest
from
libs.tools
import
tzlc
,
getMd5Digest
from
libs.es
import
ESPerform
from
libs.cache
import
redis_client
import
json
from
trans2es.commons.commons
import
get_tips_suggest_list
from
trans2es.commons.words_utils
import
QueryWordAttr
,
get_tips_word_type
from
trans2es.commons.words_utils
import
QueryWordAttr
,
get_tips_word_type
class
ProduceWikiTransfer
(
object
):
...
...
@@ -35,7 +35,7 @@ class ProduceWikiTransfer(object):
suggest_list
=
get_tips_suggest_list
(
instance
.
name
)
return
(
item_dict
,
suggest_list
)
return
(
item_dict
,
suggest_list
)
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
([],[])
\ No newline at end of file
return
([],
[])
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