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
a5d195d9
Commit
a5d195d9
authored
Jan 21, 2019
by
段英荣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add
parent
b4362b77
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
82 additions
and
6 deletions
+82
-6
settings.py
search_tips/settings.py
+1
-1
trans2es_tipsdata2es.py
trans2es/management/commands/trans2es_tipsdata2es.py
+44
-0
suggest.json
trans2es/mapping/suggest.json
+1
-1
doctor_transfer.py
trans2es/utils/doctor_transfer.py
+36
-4
No files found.
search_tips/settings.py
View file @
a5d195d9
...
@@ -28,7 +28,7 @@ SECRET_KEY = 'e%$v6snev0807=t0@gk_n2#r5m6r1h(eil6cp^y3ub@ja@gk_t'
...
@@ -28,7 +28,7 @@ SECRET_KEY = 'e%$v6snev0807=t0@gk_n2#r5m6r1h(eil6cp^y3ub@ja@gk_t'
# SECURITY WARNING: don't run with debug turned on in production!
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG
=
True
DEBUG
=
True
ALLOWED_HOSTS
=
[]
ALLOWED_HOSTS
=
[
"192.168.78.2"
]
SENTRY_CELERY_ENDPOINT
=
"http://60b0004c8884420f8067fb32fc3ed244:20f97fc73ffa4aad9735d0e6542a6d78@sentry.igengmei.com/140"
SENTRY_CELERY_ENDPOINT
=
"http://60b0004c8884420f8067fb32fc3ed244:20f97fc73ffa4aad9735d0e6542a6d78@sentry.igengmei.com/140"
BROKER_URL
=
"redis://127.0.0.1:6379/8"
BROKER_URL
=
"redis://127.0.0.1:6379/8"
...
...
trans2es/management/commands/trans2es_tipsdata2es.py
0 → 100644
View file @
a5d195d9
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import
django.db.models
from
django.conf
import
settings
from
django.core.management.base
import
BaseCommand
,
CommandError
import
traceback
import
logging
import
six
import
sys
from
libs.es
import
ESPerform
import
trans2es.models
as
md
from
libs.table_scan
import
TableSlicer
,
TableSlicerChunk
from
trans2es.type_info
import
get_type_info_map
,
TypeInfo
from
libs.cache
import
redis_client
import
json
class
Command
(
BaseCommand
):
args
=
''
help
=
'dump data to elasticsearch, parallel'
from
optparse
import
make_option
option_list
=
BaseCommand
.
option_list
+
(
make_option
(
'-t'
,
'--type'
,
dest
=
'type'
,
help
=
'type name to dump data to elasticsearch'
,
metavar
=
'TYPE'
,
default
=
''
),
make_option
(
'-i'
,
'--index-prefix'
,
dest
=
'index_prefix'
,
help
=
'index name to dump data to elasticsearch'
,
metavar
=
'INDEX_PREFIX'
),
make_option
(
'-p'
,
'--parallel'
,
dest
=
'parallel'
,
help
=
'parallel process count'
,
metavar
=
'PARALLEL'
),
make_option
(
'-s'
,
'--pks'
,
dest
=
'pks'
,
help
=
'specify sync pks, comma separated'
,
metavar
=
'PKS'
,
default
=
''
),
make_option
(
'--streaming-slicing'
,
dest
=
'streaming_slicing'
,
action
=
'store_true'
,
default
=
True
),
make_option
(
'--no-streaming-slicing'
,
dest
=
'streaming_slicing'
,
action
=
'store_false'
,
default
=
True
),
make_option
(
'-S'
,
'--sync_type'
,
dest
=
'sync_type'
,
help
=
'sync data to es'
,
metavar
=
'TYPE'
,
default
=
''
)
)
def
handle
(
self
,
*
args
,
**
options
):
try
:
logging
.
info
(
"test"
)
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
trans2es/mapping/suggest.json
View file @
a5d195d9
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
"type"
:
"completion"
"type"
:
"completion"
},
},
"suggest_type"
:{
"type"
:
"long"
},
//
0
-汉字
,
1
-汉字全拼
,
2
-拼音
,
3
-拼音全拼
,
4
-拼音简写
,
5
-拼音简写全拼
"suggest_type"
:{
"type"
:
"long"
},
//
0
-汉字
,
1
-汉字全拼
,
2
-拼音
,
3
-拼音全拼
,
4
-拼音简写
,
5
-拼音简写全拼
"
data_type"
:{
"type"
:
"long"
},
//
0
-tag
,
1
-hospital
,
2
-doctor
,
3
-wiki
"
tips_name_type"
:{
"type"
:
"long"
},
//tips数据所属类型
,
0
-tag
,
1
-hospital
,
2
-doctor
,
3
-wiki
"ori_name"
:{
"type"
:
"keyword"
},
//原名称
"ori_name"
:{
"type"
:
"keyword"
},
//原名称
"order_weight"
:{
"type"
:
"double"
},
//订单权重
"order_weight"
:{
"type"
:
"double"
},
//订单权重
"offline_score"
:{
"type"
:
"double"
},
//离线分
"offline_score"
:{
"type"
:
"double"
},
//离线分
...
...
trans2es/utils/doctor_transfer.py
View file @
a5d195d9
...
@@ -19,6 +19,35 @@ class DoctorTransfer(object):
...
@@ -19,6 +19,35 @@ class DoctorTransfer(object):
ch_prefix_weight
=
1.5
ch_prefix_weight
=
1.5
py_prefix_weight
=
1.0
py_prefix_weight
=
1.0
# 命中开始部分加权
begin_prefix_weight
=
1.2
@classmethod
def
get_doctor_data_name_mapping_results_to_redis
(
cls
,
instance
):
try
:
doctor_name
=
instance
.
name
if
doctor_name
.
strip
():
multi_fields
=
{
'hospital.city_province_name'
:
1
,
'hospital.name'
:
1
,
'name'
:
1
,
'hospital.city_name'
:
1
,
'hospital.officer_name'
:
1
,
'service_closure_tags'
:
1
}
query_fields
=
[
'^'
.
join
((
k
,
str
(
v
)))
for
(
k
,
v
)
in
multi_fields
.
items
()]
multi_match
=
{
'query'
:
doctor_name
,
'type'
:
'cross_fields'
,
'operator'
:
'and'
,
'fields'
:
query_fields
,
}
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
@classmethod
@classmethod
def
get_doctor_suggest_data_list
(
cls
,
instance
):
def
get_doctor_suggest_data_list
(
cls
,
instance
):
try
:
try
:
...
@@ -33,7 +62,7 @@ class DoctorTransfer(object):
...
@@ -33,7 +62,7 @@ class DoctorTransfer(object):
item_dict
[
"results_num"
]
=
0
item_dict
[
"results_num"
]
=
0
item_dict
[
"type_flag"
]
=
"unknown"
item_dict
[
"type_flag"
]
=
"unknown"
item_dict
[
"offline_score"
]
=
0.0
item_dict
[
"offline_score"
]
=
0.0
item_dict
[
"
data
_type"
]
=
2
item_dict
[
"
tips_name
_type"
]
=
2
ret_list
.
append
(
item_dict
)
ret_list
.
append
(
item_dict
)
suggest_list
=
list
()
suggest_list
=
list
()
...
@@ -50,9 +79,10 @@ class DoctorTransfer(object):
...
@@ -50,9 +79,10 @@ class DoctorTransfer(object):
if
ch_name_term
:
if
ch_name_term
:
prefix_weight
=
cls
.
ch_prefix_weight
if
len
(
ch_name_term
)
!=
len
(
ch_full_word
)
else
cls
.
ch_full_weight
prefix_weight
=
cls
.
ch_prefix_weight
if
len
(
ch_name_term
)
!=
len
(
ch_full_word
)
else
cls
.
ch_full_weight
suggest_type
=
0
if
len
(
ch_name_term
)
!=
len
(
ch_full_word
)
else
1
suggest_type
=
0
if
len
(
ch_name_term
)
!=
len
(
ch_full_word
)
else
1
begin_prefix_weight
=
cls
.
begin_prefix_weight
if
i
==
0
else
1.0
suggest_item
=
{
suggest_item
=
{
"input"
:[
ch_name_term
],
"input"
:[
ch_name_term
],
"word_weight"
:(
1.0
*
len
(
ch_name_term
)
/
len
((
ch_full_word
)))
*
prefix_weight
,
"word_weight"
:(
1.0
*
len
(
ch_name_term
)
/
len
((
ch_full_word
)))
*
prefix_weight
*
begin_prefix_weight
,
"suggest_type"
:
suggest_type
,
"suggest_type"
:
suggest_type
,
"cur_index"
:
cur_index
"cur_index"
:
cur_index
}
}
...
@@ -66,9 +96,10 @@ class DoctorTransfer(object):
...
@@ -66,9 +96,10 @@ class DoctorTransfer(object):
if
py_name_term
:
if
py_name_term
:
prefix_weight
=
cls
.
py_prefix_weight
if
len
(
py_name_term
)
!=
len
(
py_full_word
)
else
cls
.
py_full_weight
prefix_weight
=
cls
.
py_prefix_weight
if
len
(
py_name_term
)
!=
len
(
py_full_word
)
else
cls
.
py_full_weight
suggest_type
=
2
if
len
(
py_name_term
)
!=
len
(
py_full_word
)
else
3
suggest_type
=
2
if
len
(
py_name_term
)
!=
len
(
py_full_word
)
else
3
begin_prefix_weight
=
cls
.
begin_prefix_weight
if
i
==
0
else
1.0
suggest_item
=
{
suggest_item
=
{
"input"
:[
py_name_term
],
"input"
:[
py_name_term
],
"word_weight"
:(
1.0
*
len
(
py_name_term
)
/
len
(
py_full_word
))
*
prefix_weight
,
"word_weight"
:(
1.0
*
len
(
py_name_term
)
/
len
(
py_full_word
))
*
prefix_weight
*
begin_prefix_weight
,
"suggest_type"
:
suggest_type
,
"suggest_type"
:
suggest_type
,
"cur_index"
:
cur_index
"cur_index"
:
cur_index
}
}
...
@@ -82,9 +113,10 @@ class DoctorTransfer(object):
...
@@ -82,9 +113,10 @@ class DoctorTransfer(object):
if
py_acronym_term
:
if
py_acronym_term
:
prefix_weight
=
cls
.
py_acronym_prefix_weight
if
len
(
py_acronym_term
)
!=
len
(
py_acronym_full_word
)
else
cls
.
py_acronym_full_weight
prefix_weight
=
cls
.
py_acronym_prefix_weight
if
len
(
py_acronym_term
)
!=
len
(
py_acronym_full_word
)
else
cls
.
py_acronym_full_weight
suggest_type
=
4
if
len
(
py_acronym_term
)
!=
len
(
py_acronym_full_word
)
else
5
suggest_type
=
4
if
len
(
py_acronym_term
)
!=
len
(
py_acronym_full_word
)
else
5
begin_prefix_weight
=
cls
.
begin_prefix_weight
if
i
==
0
else
1.0
suggest_item
=
{
suggest_item
=
{
"input"
:[
py_acronym_term
],
"input"
:[
py_acronym_term
],
"word_weight"
:(
1.0
*
len
(
py_acronym_term
)
/
len
(
py_acronym_full_word
))
*
prefix_weight
,
"word_weight"
:(
1.0
*
len
(
py_acronym_term
)
/
len
(
py_acronym_full_word
))
*
prefix_weight
*
begin_prefix_weight
,
"suggest_type"
:
suggest_type
,
"suggest_type"
:
suggest_type
,
"cur_index"
:
cur_index
"cur_index"
:
cur_index
}
}
...
...
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