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
6e57caf2
Commit
6e57caf2
authored
Feb 10, 2020
by
lixiaofang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add
parent
338d6e89
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
72 additions
and
28 deletions
+72
-28
trans2es_mapping2es.py
trans2es/management/commands/trans2es_mapping2es.py
+2
-2
suggest-v2.json
trans2es/mapping/suggest-v2.json
+25
-0
query_word_conversion.py
trans2es/models/query_word_conversion.py
+0
-1
strategy_search_word.py
trans2es/models/strategy_search_word.py
+20
-0
wordresemble.py
trans2es/models/wordresemble.py
+3
-0
type_info.py
trans2es/type_info.py
+14
-10
search_query.py
trans2es/utils/search_query.py
+8
-15
No files found.
trans2es/management/commands/trans2es_mapping2es.py
View file @
6e57caf2
...
...
@@ -35,11 +35,11 @@ class Command(BaseCommand):
es_cli
=
ESPerform
.
get_cli
()
type_name1
=
"suggest-v1"
type_name2
=
"suggest-v2"
type_name
=
"suggest"
if
len
(
options
[
"type"
]):
if
options
[
"type"
]
==
"all"
or
type_name
==
options
[
"type"
]
or
type_name1
==
options
[
"type"
]:
if
options
[
"type"
]
==
"all"
or
type_name
==
options
[
"type"
]
or
type_name1
==
options
[
"type"
]
or
type_name2
==
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/mapping/suggest-v2.json
0 → 100644
View file @
6e57caf2
{
"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/models/query_word_conversion.py
View file @
6e57caf2
...
...
@@ -8,7 +8,6 @@ from django.db.models import Q
from
django.db
import
transaction
from
gm_types.gaia
import
TAG_ALERT_TYPE
manager
=
lambda
:
models
.
Manager
()
.
db_manager
(
using
=
'bran'
)
...
...
trans2es/models/strategy_search_word.py
0 → 100644
View file @
6e57caf2
# coding=utf8
from
__future__
import
unicode_literals
,
absolute_import
,
print_function
from
django.db
import
models
class
StrategyHistoryQueryWords
(
models
.
Model
):
"""
历史搜索词
"""
class
Meta
:
app_label
=
'api'
db_table
=
'strategy_history_query_words'
keyword
=
models
.
CharField
(
u'项目介绍'
,
max_length
=
48
)
is_delete
=
models
.
BooleanField
(
u'是否上线'
,
default
=
True
)
search_num
=
models
.
IntegerField
(
verbose_name
=
u'搜索次数'
)
answer_num
=
models
.
IntegerField
(
verbose_name
=
u'回答搜索结果次数'
)
tractate_num
=
models
.
IntegerField
(
verbose_name
=
u'帖子搜索结果次数'
)
diary_num
=
models
.
IntegerField
(
verbose_name
=
u'日记搜索结果次数'
)
trans2es/models/wordresemble.py
View file @
6e57caf2
...
...
@@ -14,6 +14,8 @@ from django.utils import timezone
from
gm_upload
import
IMG_TYPE
,
ImgUrlField
from
gm_types.gaia
import
WORDREL_CATEGORY
doris_manager
=
lambda
:
models
.
Manager
()
.
db_manager
(
using
=
'doris'
)
class
WordRel
(
models
.
Model
):
class
Meta
:
...
...
@@ -29,6 +31,7 @@ class WordRel(models.Model):
class
WordRelResemble
(
models
.
Model
):
"""近义词数据表
"""
class
Meta
:
app_label
=
'api'
db_table
=
'api_wordrelresemble'
...
...
trans2es/type_info.py
View file @
6e57caf2
...
...
@@ -13,7 +13,8 @@ import elasticsearch.helpers
import
sys
import
copy
from
trans2es.models
import
doctor
,
itemwiki
,
collectwiki
,
brandwiki
,
productwiki
,
tag
,
wordresemble
from
trans2es.models
import
doctor
,
itemwiki
,
collectwiki
,
brandwiki
,
productwiki
,
tag
,
wordresemble
,
\
strategy_search_word
from
trans2es.utils.doctor_transfer
import
DoctorTransfer
from
trans2es.utils.hospital_transfer
import
HospitalTransfer
from
trans2es.utils.itemwiki_transfer
import
ItemWikiTransfer
...
...
@@ -140,7 +141,7 @@ class TypeInfo(object):
(
item_dict
,
suggest_list
)
=
data
if
item_dict
:
if
item_dict
[
"tips_name_type"
]
==
4
:
if
item_dict
[
"tips_name_type"
]
==
4
or
item_dict
[
"tips_name_type"
]
==
5
:
instance
.
name
=
instance
.
keyword
resemble_list
=
WordResemble
.
get_word_resemble_list
(
str
(
instance
.
name
))
...
...
@@ -367,14 +368,17 @@ def get_type_info_map():
round_insert_chunk_size
=
5
,
round_insert_period
=
2
,
),
# TypeInfo(
# name='suggest',
# type='search_query', # tag
# get_data_func=SearchWord.get_search_query,
# bulk_insert_chunk_size=100,
# round_insert_chunk_size=5,
# round_insert_period=2,
# ),
TypeInfo
(
name
=
'suggest'
,
type
=
'search_query'
,
# tag
model
=
strategy_search_word
.
StrategyHistoryQueryWords
,
query_deferred
=
lambda
:
strategy_search_word
.
StrategyHistoryQueryWords
.
objects
.
using
(
settings
.
DORIS_DB_NAME
)
.
all
()
.
query
,
get_data_func
=
SearchWord
.
get_search_query
,
bulk_insert_chunk_size
=
100
,
round_insert_chunk_size
=
5
,
round_insert_period
=
2
,
),
# TypeInfo(
# name='suggest-v1',
# type='doctor_tips', # doctor
...
...
trans2es/utils/search_query.py
View file @
6e57caf2
...
...
@@ -21,29 +21,22 @@ from trans2es.utils.tag_transfer import TagTransfer
class
SearchWord
(
object
):
@classmethod
def
get_search_query
(
self
):
def
get_search_query
(
self
,
instance
):
try
:
##先拿到所有存在redis的数据存进es
key
=
"search_tips_save_query_word"
data
=
redis_client
.
get
(
key
)
if
data
:
redis_data
=
json
.
loads
(
data
,
encoding
=
"utf-8"
)
for
key
,
value
in
redis_data
.
items
():
ret_list
=
list
()
item_dict
=
dict
()
item_dict
[
"id"
]
=
getMd5Digest
(
str
(
key
))
item_dict
[
"ori_name"
]
=
key
item_dict
[
"id"
]
=
getMd5Digest
(
str
(
instance
.
keyword
))
item_dict
[
"ori_name"
]
=
instance
.
keyword
item_dict
[
"is_online"
]
=
1
item_dict
[
"order_weight"
]
=
QueryWordAttr
.
get_project_query_word_weight
(
key
)
item_dict
[
"results_num"
]
=
QueryWordAttr
.
get_query_results_num
(
key
)
item_dict
[
"type_flag"
]
=
get_tips_word_type
(
key
)
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"
]
=
5
ret_list
.
append
(
item_dict
)
suggest_list
=
get_tips_suggest_list
(
str
(
key
)
.
lower
())
suggest_list
=
get_tips_suggest_list
(
str
(
instance
.
keyword
)
.
lower
())
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