Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
P
physical
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
钟尚武
physical
Commits
dedaf52f
Commit
dedaf52f
authored
Jul 17, 2019
by
lixiaofang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add
parent
59ba0f3e
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
51 additions
and
24 deletions
+51
-24
tools.py
libs/tools.py
+3
-6
product.py
search/utils/product.py
+9
-9
product.json
trans2es/mapping/product.json
+18
-8
product_transfer.py
trans2es/utils/product_transfer.py
+21
-1
No files found.
libs/tools.py
View file @
dedaf52f
...
...
@@ -22,15 +22,13 @@ def tzlc(dt, truncate_to_sec=True):
return
timezone
(
settings
.
TIME_ZONE
)
.
normalize
(
dt
)
def
get_have_read_topic_id_list
(
device_id
,
user_id
,
query_type
):
def
get_have_read_topic_id_list
(
device_id
,
user_id
,
query_type
):
try
:
if
user_id
and
int
(
user_id
)
>
0
:
if
user_id
and
int
(
user_id
)
>
0
:
redis_key
=
"physical:home_recommend"
+
":user_id:"
+
str
(
user_id
)
+
":query_type:"
+
str
(
query_type
)
else
:
redis_key
=
"physical:home_recommend"
+
":device_id:"
+
str
(
device_id
)
+
":query_type:"
+
str
(
query_type
)
have_read_topic_id_list
=
list
()
redis_field_list
=
[
b
'have_read_topic_list'
]
redis_field_val_list
=
redis_client
.
hmget
(
redis_key
,
redis_field_list
)
...
...
@@ -40,4 +38,4 @@ def get_have_read_topic_id_list(device_id,user_id,query_type):
return
have_read_topic_id_list
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
list
()
\ No newline at end of file
return
list
()
search/utils/product.py
View file @
dedaf52f
...
...
@@ -19,8 +19,8 @@ class ProductUtils(object):
def
get_product_sku
(
cls
,
query
=
''
,
offset
=
0
,
size
=
10
,
filters
=
{}):
try
:
multi_fields
=
{
'cn_name
_pre
'
:
2
,
'en_name
_pre
'
:
2
,
'cn_name'
:
2
,
'en_name'
:
2
,
'alias'
:
2
,
'brand_cn_name'
:
2
,
'brand_en_name'
:
2
,
...
...
@@ -61,7 +61,7 @@ class ProductUtils(object):
}
}
q
[
"sort"
]
=
[{
"comment_nums"
:
{
"order"
:
"desc"
}}]
q
[
"sort"
]
=
[{
"comment_nums"
:
{
"order"
:
"desc"
}}
,
{
"cn_name_sort"
:
{
"order"
:
"asc"
}}
]
logging
.
info
(
"get product query:
%
s"
%
q
)
...
...
@@ -80,9 +80,9 @@ class ProductUtils(object):
logging
.
info
(
"get filters:
%
s"
%
filters
)
f
=
[
{
'term'
:
{
"have_image"
:
True
}},
{
'term'
:
{
"is_online"
:
True
}},
{
'term'
:
{
"is_deleted"
:
False
}},
#
{'term': {"have_image": True}},
#
{'term': {"is_online": True}},
{
"term"
:
{
"is_deleted"
:
False
}},
]
if
not
filters
:
...
...
@@ -94,12 +94,12 @@ class ProductUtils(object):
continue
if
k
==
"brand"
:
f
.
append
({
"term"
:
{
"brand_cn_name"
:
v
}})
f
.
append
({
"term"
:
{
"brand_cn_name
_pre
"
:
v
}})
if
k
==
"effect"
:
f
.
append
({
"term"
:
{
"effect_cn_name"
:
v
}})
f
.
append
({
"term"
:
{
"effect_cn_name
_pre
"
:
v
}})
if
k
==
"category"
:
f
.
append
({
"term"
:
{
"category_cn_name"
:
v
}})
f
.
append
({
"term"
:
{
"category_cn_name
_pre
"
:
v
}})
return
f
trans2es/mapping/product.json
View file @
dedaf52f
...
...
@@ -10,17 +10,27 @@
"update_time_val"
:{
"type"
:
"long"
},
//更新时间
"is_deleted"
:{
"type"
:
"boolean"
},
//是否被删除
"price"
:{
"type"
:
"double"
},
//价格
"cn_name_pre"
:{
"type"
:
"text"
,
"index"
:
"false"
},
//商品名称
"en_name_pre"
:{
"type"
:
"text"
,
"index"
:
"false"
},
//商品原名
"alias"
:{
"type"
:
"text"
,
"index"
:
"false"
},
"cn_name"
:{
"type"
:
"text"
,
"analyzer"
:
"gm_default_index"
,
"search_analyzer"
:
"gm_default_index"
},
//商品名称
"en_name"
:{
"type"
:
"text"
,
"analyzer"
:
"gm_default_index"
,
"search_analyzer"
:
"gm_default_index"
},
"alias"
:{
"type"
:
"text"
,
"analyzer"
:
"gm_default_index"
,
"search_analyzer"
:
"gm_default_index"
},
"brand_cn_name"
:{
"type"
:
"text"
,
"analyzer"
:
"gm_default_index"
,
"search_analyzer"
:
"gm_default_index"
},
"brand_en_name"
:{
"type"
:
"text"
,
"analyzer"
:
"gm_default_index"
,
"search_analyzer"
:
"gm_default_index"
},
"brand_alias"
:{
"type"
:
"text"
,
"analyzer"
:
"gm_default_index"
,
"search_analyzer"
:
"gm_default_index"
},
"category_cn_name"
:{
"type"
:
"text"
,
"analyzer"
:
"gm_default_index"
,
"search_analyzer"
:
"gm_default_index"
},
"effect_cn_name"
:{
"type"
:
"text"
,
"analyzer"
:
"gm_default_index"
,
"search_analyzer"
:
"gm_default_index"
},
"cn_name_pre"
:{
"type"
:
"text"
,
"analyzer"
:
"keyword"
},
//商品名称
"cn_name_sort"
:{
"type"
:
"text"
,
"fielddata"
:
"true"
},
//商品名称
"en_name_pre"
:{
"type"
:
"text"
,
"analyzer"
:
"keyword"
},
//商品原名
"alias_pre"
:{
"type"
:
"text"
,
"analyzer"
:
"keyword"
},
"description"
:{
"type"
:
"text"
,
"analyzer"
:
"keyword"
,
"search_analyzer"
:
"keyword"
},
"have_image"
:{
"type"
:
"boolean"
},
"comment_nums"
:{
"type"
:
"long"
},
"brand_cn_name
"
:{
"type"
:
"text"
,
"index"
:
"false
"
},
//所属品牌名称
"brand_en_name
"
:{
"type"
:
"text"
,
"index"
:
"false
"
},
//所属品牌原名
"brand_alias
"
:{
"type"
:
"text"
,
"index"
:
"false
"
},
//所属品牌别名
"category_cn_name
"
:{
"type"
:
"text"
,
"index"
:
"false
"
},
//所属类目的名称
"effect_cn_name
"
:{
"type"
:
"text"
,
"index"
:
"false
"
}
//所属功效的名称
"brand_cn_name
_pre"
:{
"type"
:
"text"
,
"analyzer"
:
"keyword
"
},
//所属品牌名称
"brand_en_name
_pre"
:{
"type"
:
"text"
,
"analyzer"
:
"keyword
"
},
//所属品牌原名
"brand_alias
_pre"
:{
"type"
:
"text"
,
"analyzer"
:
"keyword
"
},
//所属品牌别名
"category_cn_name
_pre"
:{
"type"
:
"text"
,
"analyzer"
:
"keyword
"
},
//所属类目的名称
"effect_cn_name
_pre"
:{
"type"
:
"text"
,
"analyzer"
:
"keyword
"
}
//所属功效的名称
}
}
...
...
trans2es/utils/product_transfer.py
View file @
dedaf52f
...
...
@@ -6,6 +6,7 @@ import logging
import
traceback
import
time
from
libs.tools
import
tzlc
from
pypinyin
import
lazy_pinyin
class
ProductTransfer
(
object
):
...
...
@@ -23,9 +24,18 @@ class ProductTransfer(object):
res
[
"create_time_val"
]
=
int
(
time
.
mktime
(
instance
.
create_time
.
timetuple
()))
res
[
"update_time_val"
]
=
int
(
time
.
mktime
(
instance
.
update_time
.
timetuple
()))
res
[
"price"
]
=
instance
.
price
res
[
"cn_name_sort"
]
=
''
for
i
in
lazy_pinyin
(
instance
.
cn_name
):
res
[
"cn_name_sort"
]
+=
str
(
i
[
0
])
res
[
"cn_name_pre"
]
=
instance
.
cn_name
res
[
"en_name_pre"
]
=
instance
.
en_name
res
[
"alias"
]
=
instance
.
alias
res
[
"alias_pre"
]
=
instance
.
alias
res
[
"cn_name"
]
=
instance
.
cn_name
res
[
"en_name"
]
=
instance
.
en_name
res
[
"alias_pre"
]
=
instance
.
alias
res
[
'description'
]
=
instance
.
description
res
[
"have_image"
]
=
True
if
instance
.
image
else
False
res
[
"comment_nums"
]
=
instance
.
comment_nums
...
...
@@ -34,22 +44,32 @@ class ProductTransfer(object):
res
[
"brand_cn_name"
]
=
result_name
.
get
(
"cn_name"
,
""
)
res
[
"brand_en_name"
]
=
result_name
.
get
(
"en_name"
,
""
)
res
[
"brand_alias"
]
=
result_name
.
get
(
"alias"
,
""
)
res
[
"brand_cn_name_pre"
]
=
result_name
.
get
(
"cn_name"
,
""
)
res
[
"brand_en_name_pre"
]
=
result_name
.
get
(
"en_name"
,
""
)
res
[
"brand_alias_pre"
]
=
result_name
.
get
(
"alias"
,
""
)
else
:
res
[
"brand_cn_name"
]
=
""
res
[
"brand_en_name"
]
=
""
res
[
"brand_alias"
]
=
""
res
[
"brand_cn_name_pre"
]
=
""
res
[
"brand_en_name_pre"
]
=
""
res
[
"brand_alias_pre"
]
=
""
category_cn_name
=
instance
.
get_category_en_name
()
if
category_cn_name
:
res
[
"category_cn_name"
]
=
category_cn_name
res
[
"category_cn_name_pre"
]
=
category_cn_name
else
:
res
[
"category_cn_name"
]
=
[]
res
[
"category_cn_name_pre"
]
=
[]
effect_cn_name
=
instance
.
get_effect_cn_name
()
if
effect_cn_name
:
res
[
'effect_cn_name'
]
=
effect_cn_name
res
[
'effect_cn_name_pre'
]
=
effect_cn_name
else
:
res
[
"effect_cn_name"
]
=
[]
res
[
"effect_cn_name_pre"
]
=
[]
logging
.
info
(
"get product:
%
s"
%
res
)
return
res
...
...
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