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
f0c8493a
Commit
f0c8493a
authored
Jun 12, 2019
by
段英荣
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'tips' into 'master'
Tips See merge request
!14
parents
4eecfd3d
91d442dd
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
38 additions
and
6 deletions
+38
-6
auto_tips.py
search/utils/auto_tips.py
+1
-1
trans2es_mapping2es.py
trans2es/management/commands/trans2es_mapping2es.py
+5
-1
suggest-v1.json
trans2es/mapping/suggest-v1.json
+25
-0
type_info.py
trans2es/type_info.py
+6
-3
wordresemble.py
trans2es/utils/wordresemble.py
+1
-1
No files found.
search/utils/auto_tips.py
View file @
f0c8493a
...
...
@@ -87,7 +87,7 @@ def get_suggest_tips(query, lat, lng, offset=0, size=50):
return
ret_list
else
:
QUERY_KEY
=
"query:{}:search_tip
s
"
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
))))
...
...
trans2es/management/commands/trans2es_mapping2es.py
View file @
f0c8493a
...
...
@@ -34,10 +34,14 @@ class Command(BaseCommand):
try
:
es_cli
=
ESPerform
.
get_cli
()
type_name1
=
"suggest-v1"
type_name
=
"suggest"
if
len
(
options
[
"type"
]):
if
options
[
"type"
]
==
"all"
or
type_name
==
options
[
"type"
]:
if
options
[
"type"
]
==
"all"
or
type_name
==
options
[
"type"
]
or
type_name1
==
options
[
"type"
]:
type_name
=
options
[
"type"
]
official_index_name
=
ESPerform
.
get_official_index_name
(
type_name
)
index_exists
=
es_cli
.
indices
.
exists
(
official_index_name
)
if
not
index_exists
:
...
...
trans2es/mapping/suggest-v1.json
0 → 100644
View file @
f0c8493a
{
"dynamic"
:
"strict"
,
"properties"
:
{
"id"
:{
"type"
:
"text"
},
"suggest"
:{
"analyzer"
:
"keyword"
,
"search_analyzer"
:
"keyword"
,
"type"
:
"completion"
,
"contexts"
:[
{
"name"
:
"is_online"
,
"type"
:
"category"
}
]
},
"suggest_type"
:{
"type"
:
"long"
},
//
0
-汉字
,
1
-汉字全拼
,
2
-拼音
,
3
-拼音全拼
,
4
-拼音简写
,
5
-拼音简写全拼
"tips_name_type"
:{
"type"
:
"long"
},
//tips数据所属类型
,
0
-tag
,
1
-hospital
,
2
-doctor
,
3
-wiki
"ori_name"
:{
"type"
:
"keyword"
},
//原名称
"order_weight"
:{
"type"
:
"double"
},
//订单权重
"offline_score"
:{
"type"
:
"double"
},
//离线分
"results_num"
:{
"type"
:
"integer"
},
//结果数量
"type_flag"
:{
"type"
:
"keyword"
},
"is_online"
:{
"type"
:
"boolean"
}
//上线
}
}
trans2es/type_info.py
View file @
f0c8493a
...
...
@@ -347,7 +347,8 @@ def get_type_info_map():
name
=
'suggest'
,
type
=
'wordrel_tips'
,
# tag
model
=
wordresemble
.
WordRel
,
query_deferred
=
lambda
:
wordresemble
.
WordRel
.
objects
.
all
()
.
query
,
query_deferred
=
lambda
:
wordresemble
.
WordRel
.
objects
.
filter
(
category__in
=
[
0
,
1
,
2
,
9
,
10
,
11
,
12
,
13
,
14
,
15
,
16
,
17
])
.
query
,
get_data_func
=
WordResemble
.
get_resemble_list
,
bulk_insert_chunk_size
=
100
,
round_insert_chunk_size
=
5
,
...
...
@@ -445,7 +446,8 @@ def tips_attr_sync_to_redis_type_info_map():
name
=
'suggest'
,
type
=
'wordrel_results_num'
,
# api_wordrelresemble
model
=
doctor
.
Hospital
,
query_deferred
=
lambda
:
wordresemble
.
WordRel
.
objects
.
all
()
.
query
,
query_deferred
=
lambda
:
wordresemble
.
WordRel
.
objects
.
filter
(
category__in
=
[
0
,
1
,
2
,
9
,
10
,
11
,
12
,
13
,
14
,
15
,
16
,
17
])
.
query
,
get_data_func
=
WordResemble
.
get_all_data_name_mapping_results_to_redis
,
bulk_insert_chunk_size
=
100
,
round_insert_chunk_size
=
5
,
...
...
@@ -455,7 +457,8 @@ def tips_attr_sync_to_redis_type_info_map():
name
=
'suggest'
,
type
=
'wordresemble_results_num'
,
# api_wordrelresemble
model
=
doctor
.
Hospital
,
query_deferred
=
lambda
:
wordresemble
.
WordRel
.
objects
.
all
()
.
query
,
query_deferred
=
lambda
:
wordresemble
.
WordRel
.
objects
.
filter
(
category__in
=
[
0
,
1
,
2
,
9
,
10
,
11
,
12
,
13
,
14
,
15
,
16
,
17
])
.
query
,
get_data_func
=
WordResemble
.
set_data_to_redis
,
bulk_insert_chunk_size
=
100
,
round_insert_chunk_size
=
5
,
...
...
trans2es/utils/wordresemble.py
View file @
f0c8493a
...
...
@@ -146,7 +146,7 @@ class WordResemble(object):
def
set_data_to_redis
(
cls
,
instance
):
try
:
QUERY_KEY
=
"query:{}:search_tip
s
"
QUERY_KEY
=
"query:{}:search_tip"
tips_num_redis_key_prefix
=
"search_tips:tips_mapping_num"
# result = wordresemble.WordRel.objects.all().values("keyword", "id")
...
...
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