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
370f250a
Commit
370f250a
authored
Jun 20, 2019
by
段英荣
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'test' into 'master'
Test See merge request
!16
parents
e60c514f
b42aeba1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
106 additions
and
99 deletions
+106
-99
Dockerfile
Dockerfile
+2
-2
Jenkinsfile
Jenkinsfile
+1
-1
auto_tips.py
search/utils/auto_tips.py
+1
-1
trans2es_mapping2es.py
trans2es/management/commands/trans2es_mapping2es.py
+0
-1
type_info.py
trans2es/type_info.py
+84
-83
wordresemble.py
trans2es/utils/wordresemble.py
+18
-11
No files found.
Dockerfile
View file @
370f250a
FROM
registry-vpc.cn-beijing.aliyuncs
.com/gm-base/gm-alpine:v1.3
FROM
ccr.ccs.tencentyun
.com/gm-base/gm-alpine:v1.3
COPY
./requirements.txt /tmp
...
...
@@ -50,5 +50,5 @@ COPY . /srv/apps/search_tips/
WORKDIR
/srv/apps/search_tips/
CMD
gunicorn gm_rpcd.wsgi:application -w
1
-k gevent -b 0.0.0.0:8000
CMD
gunicorn gm_rpcd.wsgi:application -w
5
-k gevent -b 0.0.0.0:8000
Jenkinsfile
View file @
370f250a
...
...
@@ -31,7 +31,7 @@ pipeline {
}
stage
(
'Build Image'
)
{
steps
{
sh
"docker build . ${params.CACHE} -t $IMAGE -f
/srv/apps/search_tips
/Dockerfile"
sh
"docker build . ${params.CACHE} -t $IMAGE -f
.
/Dockerfile"
sh
"docker push $IMAGE"
}
}
...
...
search/utils/auto_tips.py
View file @
370f250a
...
...
@@ -13,6 +13,7 @@ from libs.tools import point_distance
from
gm_rpcd.all
import
bind
from
trans2es.commons.words_utils
import
QueryWordAttr
,
get_tips_word_type
def
get_suggest_tips
(
query
,
lat
,
lng
,
offset
=
0
,
size
=
50
):
try
:
# ios输入法在某些情况下会携带\\u2006
...
...
@@ -37,7 +38,6 @@ def get_suggest_tips(query, lat, lng, offset=0, size=50):
"includes"
:
[
"id"
,
"ori_name"
,
"offline_score"
,
"is_online"
,
"type_flag"
,
"results_num"
]
}
}
logging
.
info
(
"get qqqqqqqq:
%
s"
%
q
)
have_read_tips_set
=
set
()
ret_list
=
list
()
...
...
trans2es/management/commands/trans2es_mapping2es.py
View file @
370f250a
...
...
@@ -40,7 +40,6 @@ class Command(BaseCommand):
if
len
(
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
)
...
...
trans2es/type_info.py
View file @
370f250a
...
...
@@ -137,6 +137,7 @@ class TypeInfo(object):
continue
data
=
self
.
get_data_func
(
instance
)
(
item_dict
,
suggest_list
)
=
data
if
item_dict
[
"tips_name_type"
]
==
4
:
instance
.
name
=
instance
.
keyword
...
...
@@ -354,89 +355,89 @@ def get_type_info_map():
round_insert_chunk_size
=
5
,
round_insert_period
=
2
,
),
TypeInfo
(
name
=
'suggest-v1'
,
type
=
'doctor_tips'
,
# doctor
model
=
doctor
.
Doctor
,
query_deferred
=
lambda
:
doctor
.
Doctor
.
objects
.
all
()
.
filter
(
doctor_type
=
DOCTOR_TYPE
.
DOCTOR
)
.
query
,
get_data_func
=
DoctorTransfer
.
get_doctor_suggest_data_list
,
bulk_insert_chunk_size
=
100
,
round_insert_chunk_size
=
5
,
round_insert_period
=
2
,
),
TypeInfo
(
name
=
'suggest-v1'
,
type
=
'hospital_tips'
,
# hospital
model
=
doctor
.
Hospital
,
# query_deferred=lambda: doctor.Doctor.objects.all().filter(doctor_type=DOCTOR_TYPE.OFFICER).query,
query_deferred
=
lambda
:
doctor
.
Hospital
.
objects
.
all
()
.
query
,
get_data_func
=
HospitalTransfer
.
get_hospital_suggest_data_list
,
bulk_insert_chunk_size
=
100
,
round_insert_chunk_size
=
5
,
round_insert_period
=
2
,
),
TypeInfo
(
name
=
'suggest-v1'
,
type
=
'itemwiki_tips'
,
# itemwiki
model
=
itemwiki
.
ItemWiki
,
query_deferred
=
lambda
:
itemwiki
.
ItemWiki
.
objects
.
all
()
.
query
,
get_data_func
=
ItemWikiTransfer
.
get_itemwiki_suggest_data_list
,
bulk_insert_chunk_size
=
100
,
round_insert_chunk_size
=
5
,
round_insert_period
=
2
,
),
TypeInfo
(
name
=
'suggest-v1'
,
type
=
'collectwiki_tips'
,
# collectwiki
model
=
collectwiki
.
CollectWiki
,
query_deferred
=
lambda
:
collectwiki
.
CollectWiki
.
objects
.
all
()
.
query
,
get_data_func
=
CollectWikiTransfer
.
get_collectwiki_suggest_data_list
,
bulk_insert_chunk_size
=
100
,
round_insert_chunk_size
=
5
,
round_insert_period
=
2
,
),
TypeInfo
(
name
=
'suggest-v1'
,
type
=
'brandwiki_tips'
,
# brandwiki
model
=
brandwiki
.
BrandWiki
,
query_deferred
=
lambda
:
brandwiki
.
BrandWiki
.
objects
.
all
()
.
query
,
get_data_func
=
BrandWikiTransfer
.
get_brandwiki_suggest_data_list
,
bulk_insert_chunk_size
=
100
,
round_insert_chunk_size
=
5
,
round_insert_period
=
2
,
),
TypeInfo
(
name
=
'suggest-v1'
,
type
=
'productwiki_tips'
,
# productwiki
model
=
productwiki
.
ProductWiki
,
query_deferred
=
lambda
:
productwiki
.
ProductWiki
.
objects
.
all
()
.
query
,
get_data_func
=
ProduceWikiTransfer
.
get_productwiki_suggest_data_list
,
bulk_insert_chunk_size
=
100
,
round_insert_chunk_size
=
5
,
round_insert_period
=
2
,
),
TypeInfo
(
name
=
'suggest-v1'
,
type
=
'tag_tips'
,
# tag
model
=
tag
.
Tag
,
query_deferred
=
lambda
:
tag
.
Tag
.
objects
.
all
()
.
filter
(
tag_type__in
=
[
TAG_TYPE
.
BODY_PART
,
TAG_TYPE
.
BODY_PART_SUB_ITEM
,
TAG_TYPE
.
ITEM_WIKI
])
.
query
,
get_data_func
=
TagTransfer
.
get_tag_suggest_data_list
,
bulk_insert_chunk_size
=
100
,
round_insert_chunk_size
=
5
,
round_insert_period
=
2
,
),
TypeInfo
(
name
=
'suggest-v1'
,
type
=
'wordrel_tips'
,
# tag
model
=
wordresemble
.
WordRel
,
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
,
round_insert_period
=
2
,
)
#
TypeInfo(
#
name='suggest-v1',
#
type='doctor_tips', # doctor
#
model=doctor.Doctor,
#
query_deferred=lambda: doctor.Doctor.objects.all().filter(doctor_type=DOCTOR_TYPE.DOCTOR).query,
#
get_data_func=DoctorTransfer.get_doctor_suggest_data_list,
#
bulk_insert_chunk_size=100,
#
round_insert_chunk_size=5,
#
round_insert_period=2,
#
),
#
TypeInfo(
#
name='suggest-v1',
#
type='hospital_tips', # hospital
#
model=doctor.Hospital,
#
# query_deferred=lambda: doctor.Doctor.objects.all().filter(doctor_type=DOCTOR_TYPE.OFFICER).query,
#
query_deferred=lambda: doctor.Hospital.objects.all().query,
#
get_data_func=HospitalTransfer.get_hospital_suggest_data_list,
#
bulk_insert_chunk_size=100,
#
round_insert_chunk_size=5,
#
round_insert_period=2,
#
),
#
TypeInfo(
#
name='suggest-v1',
#
type='itemwiki_tips', # itemwiki
#
model=itemwiki.ItemWiki,
#
query_deferred=lambda: itemwiki.ItemWiki.objects.all().query,
#
get_data_func=ItemWikiTransfer.get_itemwiki_suggest_data_list,
#
bulk_insert_chunk_size=100,
#
round_insert_chunk_size=5,
#
round_insert_period=2,
#
),
#
TypeInfo(
#
name='suggest-v1',
#
type='collectwiki_tips', # collectwiki
#
model=collectwiki.CollectWiki,
#
query_deferred=lambda: collectwiki.CollectWiki.objects.all().query,
#
get_data_func=CollectWikiTransfer.get_collectwiki_suggest_data_list,
#
bulk_insert_chunk_size=100,
#
round_insert_chunk_size=5,
#
round_insert_period=2,
#
),
#
TypeInfo(
#
name='suggest-v1',
#
type='brandwiki_tips', # brandwiki
#
model=brandwiki.BrandWiki,
#
query_deferred=lambda: brandwiki.BrandWiki.objects.all().query,
#
get_data_func=BrandWikiTransfer.get_brandwiki_suggest_data_list,
#
bulk_insert_chunk_size=100,
#
round_insert_chunk_size=5,
#
round_insert_period=2,
#
),
#
TypeInfo(
#
name='suggest-v1',
#
type='productwiki_tips', # productwiki
#
model=productwiki.ProductWiki,
#
query_deferred=lambda: productwiki.ProductWiki.objects.all().query,
#
get_data_func=ProduceWikiTransfer.get_productwiki_suggest_data_list,
#
bulk_insert_chunk_size=100,
#
round_insert_chunk_size=5,
#
round_insert_period=2,
#
),
#
TypeInfo(
#
name='suggest-v1',
#
type='tag_tips', # tag
#
model=tag.Tag,
#
query_deferred=lambda: tag.Tag.objects.all().filter(
#
tag_type__in=[TAG_TYPE.BODY_PART, TAG_TYPE.BODY_PART_SUB_ITEM, TAG_TYPE.ITEM_WIKI]).query,
#
get_data_func=TagTransfer.get_tag_suggest_data_list,
#
bulk_insert_chunk_size=100,
#
round_insert_chunk_size=5,
#
round_insert_period=2,
#
),
#
TypeInfo(
#
name='suggest-v1',
#
type='wordrel_tips', # tag
#
model=wordresemble.WordRel,
#
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,
#
round_insert_period=2,
#
)
]
type_info_map
=
{
...
...
trans2es/utils/wordresemble.py
View file @
370f250a
...
...
@@ -43,20 +43,27 @@ class WordResemble(object):
try
:
try
:
ret_list
=
list
()
item_dict
=
dict
()
item_dict
[
"id"
]
=
getMd5Digest
(
str
(
instance
.
keyword
))
item_dict
[
"ori_name"
]
=
instance
.
keyword
item_dict
[
"is_online"
]
=
True
item_dict
[
"order_weight"
]
=
QueryWordAttr
.
get_project_query_word_weight
(
instance
.
keyword
)
item_dict
[
"results_num"
]
=
QueryWordAttr
.
get_query_results_num
(
instance
.
keyword
)
item_dict
[
"type_flag"
]
=
get_tips_word_type
(
instance
.
keyword
)
item_dict
[
"offline_score"
]
=
0.0
item_dict
[
"tips_name_type"
]
=
4
ret_list
.
append
(
item_dict
)
suggest_list
=
get_tips_suggest_list
(
instance
.
keyword
)
keyword
=
instance
.
keyword
cut_bool
=
False
cut_word
=
[
"下线"
,
"停用"
,
"已经下线"
,
"账号停用"
]
for
i
in
cut_word
:
if
keyword
.
find
(
i
)
>=
0
:
cut_bool
=
True
if
cut_bool
==
False
:
item_dict
[
"id"
]
=
getMd5Digest
(
str
(
instance
.
keyword
))
item_dict
[
"ori_name"
]
=
instance
.
keyword
item_dict
[
"is_online"
]
=
True
item_dict
[
"order_weight"
]
=
QueryWordAttr
.
get_project_query_word_weight
(
instance
.
keyword
)
item_dict
[
"results_num"
]
=
QueryWordAttr
.
get_query_results_num
(
instance
.
keyword
)
item_dict
[
"type_flag"
]
=
get_tips_word_type
(
instance
.
keyword
)
item_dict
[
"offline_score"
]
=
0.0
item_dict
[
"tips_name_type"
]
=
4
ret_list
.
append
(
item_dict
)
suggest_list
=
get_tips_suggest_list
(
instance
.
keyword
)
return
(
item_dict
,
suggest_list
)
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
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