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
9e5b00f8
Commit
9e5b00f8
authored
Feb 13, 2019
by
段英荣
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev' into 'test'
Dev See merge request
!9
parents
02d3ce94
80561432
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
27 deletions
+33
-27
es.py
libs/es.py
+2
-2
auto_tips.py
search/utils/auto_tips.py
+23
-20
commons.py
trans2es/commons/commons.py
+5
-5
type_info.py
trans2es/type_info.py
+3
-0
No files found.
libs/es.py
View file @
9e5b00f8
...
...
@@ -22,8 +22,8 @@ class ESPerform(object):
def
get_cli
(
cls
,
es_ip_list
=
None
):
try
:
es_info_list
=
es_ip_list
if
es_ip_list
else
cls
.
cli_info_list
if
es_ip_list
:
#tricky的做法,兼容测试es
cls
.
index_prefix
=
"gm_test"
#
if es_ip_list:#tricky的做法,兼容测试es
#
cls.index_prefix = "gm_test"
cls
.
cli_obj
=
Elasticsearch
(
es_info_list
)
return
cls
.
cli_obj
...
...
search/utils/auto_tips.py
View file @
9e5b00f8
...
...
@@ -33,39 +33,42 @@ def get_suggest_tips(query,lat,lng,offset=0,size=50):
}
},
"_source"
:
{
"include"
:
[
"id"
,
"ori_name"
,
"offline_score"
,
"is_online"
,
"type_flag"
,
"results_num"
]
"include
s
"
:
[
"id"
,
"ori_name"
,
"offline_score"
,
"is_online"
,
"type_flag"
,
"results_num"
]
}
}
have_read_tips_set
=
set
()
ret_list
=
list
()
result_dict
=
ESPerform
.
get_search_results
(
ESPerform
.
get_cli
(),
sub_index_name
=
"suggest"
,
query_body
=
q
,
offset
=
offset
,
size
=
size
,
is_suggest_request
=
True
)
for
tips_item
in
result_dict
[
"suggest"
][
"tips-suggest"
]:
for
hit_item
in
tips_item
[
"options"
]:
highlight_marks
=
u'<ems>
%
s</ems>'
%
query
hit_item
[
"_source"
][
"highlight_name"
]
=
hit_item
[
"_source"
][
"ori_name"
]
.
replace
(
query
,
highlight_marks
)
if
hit_item
[
"_source"
][
"ori_name"
]
not
in
have_read_tips_set
:
have_read_tips_set
.
add
(
hit_item
[
"_source"
][
"ori_name"
])
highlight_marks
=
u'<ems>
%
s</ems>'
%
query
hit_item
[
"_source"
][
"highlight_name"
]
=
hit_item
[
"_source"
][
"ori_name"
]
.
replace
(
query
,
highlight_marks
)
if
hit_item
[
"_source"
][
"type_flag"
]
==
"hospital"
:
if
hit_item
[
"_source"
][
"ori_name"
]
in
g_hospital_pos_dict
:
distance
=
point_distance
(
lng
,
lat
,
g_hospital_pos_dict
[
hit_item
[
"_source"
][
"ori_name"
]][
0
],
g_hospital_pos_dict
[
hit_item
[
"_source"
][
"ori_name"
]][
1
])
if
distance
<
1000
*
50
:
if
distance
<
1000
:
if
distance
<
100
:
hit_item
[
"_source"
][
"describe"
]
=
"<100"
+
"米"
if
hit_item
[
"_source"
][
"type_flag"
]
==
"hospital"
:
if
hit_item
[
"_source"
][
"ori_name"
]
in
g_hospital_pos_dict
:
distance
=
point_distance
(
lng
,
lat
,
g_hospital_pos_dict
[
hit_item
[
"_source"
][
"ori_name"
]][
0
],
g_hospital_pos_dict
[
hit_item
[
"_source"
][
"ori_name"
]][
1
])
if
distance
<
1000
*
50
:
if
distance
<
1000
:
if
distance
<
100
:
hit_item
[
"_source"
][
"describe"
]
=
"<100"
+
"米"
else
:
hit_item
[
"_source"
][
"describe"
]
=
"约"
+
str
(
int
(
distance
))
+
"米"
else
:
hit_item
[
"_source"
][
"describe"
]
=
"约"
+
str
(
int
(
distance
))
+
"米
"
hit_item
[
"_source"
][
"describe"
]
=
"约"
+
str
(
round
(
1.0
*
distance
/
1000
,
1
))
+
"km
"
else
:
hit_item
[
"_source"
][
"describe"
]
=
"
约"
+
str
(
round
(
1.0
*
distance
/
1000
,
1
))
+
"
km"
hit_item
[
"_source"
][
"describe"
]
=
"
>50
km"
else
:
hit_item
[
"_source"
][
"describe"
]
=
"
>50km
"
hit_item
[
"_source"
][
"describe"
]
=
""
else
:
hit_item
[
"_source"
][
"describe"
]
=
""
else
:
if
hit_item
[
"_source"
][
"type_flag"
]
==
"doctor"
:
hit_item
[
"_source"
][
"describe"
]
=
""
else
:
hit_item
[
"_source"
][
"describe"
]
=
"约"
+
str
(
hit_item
[
"_source"
][
"results_num"
])
+
"个结果"
if
hit_item
[
"_source"
][
"results_num"
]
else
""
ret_list
.
append
(
hit_item
[
"_source"
])
if
hit_item
[
"_source"
][
"type_flag"
]
==
"doctor"
:
hit_item
[
"_source"
][
"describe"
]
=
""
else
:
hit_item
[
"_source"
][
"describe"
]
=
"约"
+
str
(
hit_item
[
"_source"
][
"results_num"
])
+
"个结果"
if
hit_item
[
"_source"
][
"results_num"
]
else
""
ret_list
.
append
(
hit_item
[
"_source"
])
return
ret_list
except
:
...
...
trans2es/commons/commons.py
View file @
9e5b00f8
...
...
@@ -21,8 +21,9 @@ def uuid4():
def
get_tips_suggest_list
(
instance_cn_name
):
try
:
ch_full_weight
=
6.0
*
1000
py_full_weight
=
3.0
*
1000
#ch_full_weight = 6.0 * 1000
#py_full_weight = 3.0 * 1000
full_weight
=
3.0
*
1000
py_acronym_full_weight
=
3.0
*
1000
py_acronym_prefix_weight
=
2
...
...
@@ -42,7 +43,7 @@ def get_tips_suggest_list(instance_cn_name):
for
i
in
range
(
len
(
ch_full_word
)):
ch_name_term
=
ch_full_word
[
i
:]
.
strip
()
if
ch_name_term
and
ch_full_word
[
i
]
!=
"("
and
ch_full_word
[
i
]
!=
")"
:
prefix_weight
=
ch_prefix_weight
if
len
(
ch_name_term
)
!=
len
(
ch_full_word
)
else
ch_
full_weight
prefix_weight
=
ch_prefix_weight
if
len
(
ch_name_term
)
!=
len
(
ch_full_word
)
else
full_weight
suggest_type
=
0
if
len
(
ch_name_term
)
!=
len
(
ch_full_word
)
else
1
term_begin_prefix_weight
=
begin_prefix_weight
if
i
==
0
else
1.0
suggest_item
=
{
...
...
@@ -64,8 +65,7 @@ def get_tips_suggest_list(instance_cn_name):
for
i
in
range
(
len
(
py_full_word
)):
py_name_term
=
py_full_word
[
i
:]
.
strip
()
if
py_name_term
and
py_full_word
[
i
]
!=
"("
and
py_full_word
[
i
]
!=
")"
:
prefix_weight
=
py_prefix_weight
if
len
(
py_name_term
)
!=
len
(
py_full_word
)
else
py_full_weight
prefix_weight
=
py_prefix_weight
if
len
(
py_name_term
)
!=
len
(
py_full_word
)
else
full_weight
suggest_type
=
2
if
len
(
py_name_term
)
!=
len
(
py_full_word
)
else
3
term_begin_prefix_weight
=
begin_prefix_weight
if
i
==
0
else
1.0
suggest_item
=
{
...
...
trans2es/type_info.py
View file @
9e5b00f8
...
...
@@ -24,6 +24,8 @@ from trans2es.utils.tag_transfer import TagTransfer
from
trans2es.utils.wordresemble
import
WordResemble
from
libs.es
import
ESPerform
from
libs.tools
import
tzlc
,
getMd5Digest
from
trans2es.commons.words_utils
import
QueryWordAttr
from
gm_types.gaia
import
SERVICE_ITEM_PRICE_TYPE
,
DOCTOR_TYPE
from
gm_types.gaia
import
(
...
...
@@ -155,6 +157,7 @@ class TypeInfo(object):
resemble_dict
=
copy
.
deepcopy
(
suggest_dict
)
resemble_dict
[
"id"
]
=
suggest_dict
[
"id"
]
+
"_"
+
getMd5Digest
(
resemble_item
)
resemble_dict
[
"ori_name"
]
=
resemble_item
resemble_dict
[
"results_num"
]
=
QueryWordAttr
.
get_query_results_num
(
resemble_item
)
resemble_dict
[
"offline_score"
]
=
0
resemble_dict
[
"suggest"
][
"weight"
]
=
0
data_list
.
append
(
resemble_dict
)
...
...
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