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
ae39eda7
Commit
ae39eda7
authored
Feb 11, 2020
by
lixiaofang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add
parent
2d063776
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
96 additions
and
4 deletions
+96
-4
trans2es_mapping2es.py
trans2es/management/commands/trans2es_mapping2es.py
+2
-2
suggest-v2.json
trans2es/mapping/suggest-v2.json
+25
-0
strategy_search_word.py
trans2es/models/strategy_search_word.py
+21
-0
type_info.py
trans2es/type_info.py
+16
-2
search_query.py
trans2es/utils/search_query.py
+32
-0
No files found.
trans2es/management/commands/trans2es_mapping2es.py
View file @
ae39eda7
...
...
@@ -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 @
ae39eda7
{
"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/strategy_search_word.py
0 → 100644
View file @
ae39eda7
# coding=utf8
from
__future__
import
unicode_literals
,
absolute_import
,
print_function
from
django.db
import
models
from
django.conf
import
settings
class
StrategyHistoryQueryWords
(
models
.
Model
):
"""
历史搜索词
"""
class
Meta
:
app_label
=
'doris'
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/type_info.py
View file @
ae39eda7
...
...
@@ -13,7 +13,7 @@ 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
...
...
@@ -22,6 +22,8 @@ from trans2es.utils.brandwiki_transfer import BrandWikiTransfer
from
trans2es.utils.productwiki_transfer
import
ProduceWikiTransfer
from
trans2es.utils.tag_transfer
import
TagTransfer
from
trans2es.utils.wordresemble
import
WordResemble
from
trans2es.utils.search_query
import
SearchWord
from
libs.es
import
ESPerform
from
libs.tools
import
tzlc
,
getMd5Digest
from
trans2es.commons.words_utils
import
QueryWordAttr
...
...
@@ -139,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
))
...
...
@@ -365,6 +367,18 @@ def get_type_info_map():
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
0 → 100644
View file @
ae39eda7
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import
logging
import
traceback
from
libs.tools
import
getMd5Digest
from
trans2es.commons.words_utils
import
QueryWordAttr
,
get_tips_word_type
from
trans2es.commons.commons
import
get_tips_suggest_list
class
SearchWord
(
object
):
@classmethod
def
get_search_query
(
self
,
instance
):
try
:
print
(
"=-=-=-=-=-=-"
)
ret_list
=
list
()
item_dict
=
dict
()
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
(
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
(
instance
.
keyword
)
.
lower
(),
is_weighting
=
True
)
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