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
3cfbd8f3
Commit
3cfbd8f3
authored
Jun 11, 2019
by
lixiaofang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add
parent
59730e1f
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
20 additions
and
47 deletions
+20
-47
es.py
libs/es.py
+0
-24
auto_tips.py
search/utils/auto_tips.py
+4
-6
words_utils.py
trans2es/commons/words_utils.py
+1
-1
type_info.py
trans2es/type_info.py
+10
-0
itemwiki_transfer.py
trans2es/utils/itemwiki_transfer.py
+2
-5
tag_transfer.py
trans2es/utils/tag_transfer.py
+2
-2
wordresemble.py
trans2es/utils/wordresemble.py
+1
-9
No files found.
libs/es.py
View file @
3cfbd8f3
...
...
@@ -208,27 +208,3 @@ class ESPerform(object):
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
{
"total_count"
:
0
,
"hits"
:
[]}
@classmethod
def
es_indices_analyze
(
cls
,
doc_type
,
body
,
es
):
if
es
is
None
:
es
=
ESPerform
.
get_cli
(
settings
.
GM_ORI_ES_INFO_LIST
)
index
=
ESPerform
.
es_index_adapt
(
index_prefix
=
settings
.
ES_INDEX_PREFIX
,
doc_type
=
doc_type
,
rw
=
'read'
)
res
=
es
.
indices
.
analyze
(
index
=
index
,
body
=
body
)
return
res
@classmethod
def
es_index_adapt
(
cls
,
index_prefix
,
doc_type
,
rw
=
None
):
"""get the adapted index name
"""
assert
rw
in
[
None
,
'read'
,
'write'
]
index
=
'-'
.
join
((
index_prefix
,
doc_type
))
if
rw
:
index
=
'-'
.
join
((
index
,
rw
))
return
index
search/utils/auto_tips.py
View file @
3cfbd8f3
...
...
@@ -109,13 +109,11 @@ def get_suggest_tips(query, lat, lng, offset=0, size=50):
"offline_score"
:
0
,
"type_flag"
:
get_tips_word_type
(
ori_name
),
"highlight_name"
:
ori_name
,
"describe"
:
""
})
return
ret_list
if
len
(
ret_list
>=
50
):
return
ret_list
[
0
:
50
]
else
:
return
ret_list
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
...
...
trans2es/commons/words_utils.py
View file @
3cfbd8f3
...
...
@@ -198,9 +198,9 @@ def get_tips_word_type(query=''):
key
=
QUERY_KEY
.
format
(
query_base64
)
labels
=
list
(
map
(
lambda
x
:
x
.
decode
(
"utf8"
),
list
(
redis_client
.
smembers
(
key
))))
labels
.
append
(
MIND_TYPE
.
UNKNOWN
)
if
query
in
QUERY_WORD_LABEL_NEED_MODIFIED
:
labels
.
append
(
MIND_TYPE
.
PROJECT
)
logging
.
info
(
"get labels:
%
s"
%
labels
)
labels
.
sort
(
key
=
label_key
,
reverse
=
True
)
return
labels
[
0
]
trans2es/type_info.py
View file @
3cfbd8f3
...
...
@@ -463,6 +463,16 @@ def tips_attr_sync_to_redis_type_info_map():
bulk_insert_chunk_size
=
100
,
round_insert_chunk_size
=
5
,
round_insert_period
=
2
,
),
TypeInfo
(
name
=
'suggest'
,
type
=
'wordresemble_results_num'
,
# api_wordrelresemble
model
=
doctor
.
Hospital
,
query_deferred
=
lambda
:
wordresemble
.
WordRel
.
objects
.
all
()
.
query
,
get_data_func
=
WordResemble
.
set_data_to_redis
,
bulk_insert_chunk_size
=
100
,
round_insert_chunk_size
=
5
,
round_insert_period
=
2
,
)
]
...
...
trans2es/utils/itemwiki_transfer.py
View file @
3cfbd8f3
...
...
@@ -68,17 +68,14 @@ class ItemWikiTransfer(object):
redis_val_dict
=
json
.
loads
(
str
(
redis_data
,
encoding
=
"utf-8"
))
if
redis_data
else
{}
total_count
=
doctor_results
if
'
w
'
in
redis_val_dict
:
total_count
+=
int
(
redis_val_dict
[
'
w
'
])
if
'
t
'
in
redis_val_dict
:
total_count
+=
int
(
redis_val_dict
[
'
t
'
])
redis_val_dict
[
't'
]
=
total_count
redis_val_dict
[
'w'
]
=
doctor_results
redis_client
.
hset
(
redis_key_prefix
,
wiki_name
,
json
.
dumps
(
redis_val_dict
))
logging
.
info
(
"get ----------------------get "
)
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
...
...
trans2es/utils/tag_transfer.py
View file @
3cfbd8f3
...
...
@@ -77,8 +77,8 @@ class TagTransfer(object):
redis_val_dict
=
json
.
loads
(
str
(
redis_data
,
encoding
=
"utf-8"
))
if
redis_data
else
{}
total_count
=
doctor_results
if
'
s
'
in
redis_val_dict
:
total_count
+=
int
(
redis_val_dict
[
'
s
'
])
if
'
t
'
in
redis_val_dict
:
total_count
+=
int
(
redis_val_dict
[
'
t
'
])
redis_val_dict
[
't'
]
=
total_count
redis_val_dict
[
's'
]
=
doctor_results
...
...
trans2es/utils/wordresemble.py
View file @
3cfbd8f3
...
...
@@ -143,7 +143,7 @@ class WordResemble(object):
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
@classmethod
def
set_data_to_redis
(
cls
):
def
set_data_to_redis
(
cls
,
instance
):
try
:
QUERY_KEY
=
"query:{}:search_tips"
...
...
@@ -156,8 +156,6 @@ class WordResemble(object):
words
=
list
(
sql_obj
.
all_resembles
.
all
()
.
values_list
(
'word'
,
flat
=
True
))
for
items
in
words
:
# 先存储本体词
logging
.
info
(
"get wordrm:
%
s"
%
wordrm
[
"keyword"
])
logging
.
info
(
"get words:
%
s"
%
words
)
query_base64
=
base64
.
b64encode
(
wordrm
[
"keyword"
]
.
encode
(
'utf8'
))
.
decode
(
'utf8'
)
key
=
QUERY_KEY
.
format
(
query_base64
)
value_name
=
base64
.
b64encode
(
items
.
encode
(
'utf8'
))
.
decode
(
'utf8'
)
...
...
@@ -171,8 +169,6 @@ class WordResemble(object):
# 存储到Redis
value
=
value_name
+
str
(
":"
+
str
(
total_count
))
redis_client
.
sadd
(
key
,
value
)
logging
.
info
(
"get value:
%
s"
%
value
)
# 存储近义词
query_base64
=
base64
.
b64encode
(
items
.
encode
(
'utf8'
))
.
decode
(
'utf8'
)
key
=
QUERY_KEY
.
format
(
query_base64
)
...
...
@@ -186,10 +182,8 @@ class WordResemble(object):
# 存储结果
value
=
value_name
+
str
(
":"
+
str
(
total_count
))
redis_client
.
sadd
(
key
,
value
)
logging
.
info
(
"get value:
%
s"
%
value
)
if
words
:
for
w
in
words
:
logging
.
info
(
"get word_pops:
%
s"
%
words
)
value_name
=
base64
.
b64encode
(
w
.
encode
(
'utf8'
))
.
decode
(
'utf8'
)
redis_data
=
redis_client
.
hget
(
tips_num_redis_key_prefix
,
w
)
redis_val_dict
=
json
.
loads
(
str
(
redis_data
,
encoding
=
"utf-8"
))
if
redis_data
else
{}
...
...
@@ -198,8 +192,6 @@ class WordResemble(object):
total_count
=
int
(
redis_val_dict
[
't'
])
value
=
value_name
+
str
(
":"
+
str
(
total_count
))
redis_client
.
sadd
(
key
,
value
)
logging
.
info
(
"get value:
%
s"
%
value
)
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
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