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
fd94d0d2
Commit
fd94d0d2
authored
Jun 06, 2019
by
lixiaofang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mapping
parent
6fdcd970
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
14 deletions
+23
-14
auto_tips.py
search/utils/auto_tips.py
+1
-1
trans2es_mapping2es.py
trans2es/management/commands/trans2es_mapping2es.py
+22
-13
No files found.
search/utils/auto_tips.py
View file @
fd94d0d2
...
@@ -57,7 +57,7 @@ def get_suggest_tips(query, lat, lng, offset=0, size=50):
...
@@ -57,7 +57,7 @@ def get_suggest_tips(query, lat, lng, offset=0, size=50):
if
hit_item
[
"_source"
][
"type_flag"
]
==
"hospital"
:
if
hit_item
[
"_source"
][
"type_flag"
]
==
"hospital"
:
if
lat
is
not
None
and
lng
is
not
None
:
if
lat
is
not
None
and
lng
is
not
None
and
lat
!=
0.0
and
lng
!=
0.0
:
if
hit_item
[
"_source"
][
"ori_name"
]
in
g_hospital_pos_dict
:
if
hit_item
[
"_source"
][
"ori_name"
]
in
g_hospital_pos_dict
:
distance
=
point_distance
(
lng
,
lat
,
distance
=
point_distance
(
lng
,
lat
,
g_hospital_pos_dict
[
hit_item
[
"_source"
][
"ori_name"
]][
0
],
g_hospital_pos_dict
[
hit_item
[
"_source"
][
"ori_name"
]][
0
],
...
...
trans2es/management/commands/trans2es_mapping2es.py
View file @
fd94d0d2
...
@@ -2,11 +2,11 @@
...
@@ -2,11 +2,11 @@
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
from
django.conf
import
settings
from
django.conf
import
settings
from
django.core.management.base
import
BaseCommand
,
CommandError
from
django.core.management.base
import
BaseCommand
import
traceback
import
traceback
import
logging
import
logging
from
libs.es
import
ESPerform
from
libs.es
import
ESPerform
from
trans2es.type_info
import
get_type_info_map
,
TypeInfo
from
trans2es.type_info
import
get_type_info_map
class
Command
(
BaseCommand
):
class
Command
(
BaseCommand
):
...
@@ -30,22 +30,31 @@ class Command(BaseCommand):
...
@@ -30,22 +30,31 @@ class Command(BaseCommand):
)
)
def
handle
(
self
,
*
args
,
**
options
):
def
handle
(
self
,
*
args
,
**
options
):
try
:
try
:
if
not
options
[
'type'
]:
raise
logging
.
info
(
'type name must be specified'
)
elif
not
(
options
[
'type'
]
in
[
'suggest'
,
]):
raise
logging
.
info
(
'unknown type name, type must be one of [suggest]'
)
es_cli
=
ESPerform
.
get_cli
()
es_cli
=
ESPerform
.
get_cli
()
type_name_list
=
get_type_info_map
()
.
keys
()
type_name
=
"suggest"
for
type_name
in
type_name_list
:
if
len
(
options
[
"type"
]):
if
len
(
options
[
"type"
]):
if
options
[
"type"
]
==
"all"
or
type_name
==
options
[
"type"
]:
if
options
[
"type"
]
==
"all"
or
type_name
==
options
[
"type"
]:
official_index_name
=
ESPerform
.
get_official_index_name
(
type_name
)
official_index_name
=
ESPerform
.
get_official_index_name
(
type_name
)
index_exists
=
es_cli
.
indices
.
exists
(
official_index_name
)
index_exists
=
es_cli
.
indices
.
exists
(
official_index_name
)
if
not
index_exists
:
if
not
index_exists
:
logging
.
info
(
"begin create [
%
s] index!"
%
type_name
)
logging
.
info
(
"begin create [
%
s] index!"
%
type_name
)
ESPerform
.
create_index
(
es_cli
,
type_name
)
ESPerform
.
create_index
(
es_cli
,
type_name
)
logging
.
info
(
"begin create [
%
s] mapping!"
%
type_name
)
logging
.
info
(
"begin create [
%
s] mapping!"
%
type_name
)
ESPerform
.
put_index_mapping
(
es_cli
,
type_name
)
ESPerform
.
put_index_mapping
(
es_cli
,
type_name
)
if
len
(
options
[
"indices_template"
]):
if
len
(
options
[
"indices_template"
]):
template_file_name
=
options
[
"indices_template"
]
template_file_name
=
options
[
"indices_template"
]
...
...
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