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
359b90f6
Commit
359b90f6
authored
Jul 17, 2019
by
lixiaofang
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '721_goods-sort' into test
parents
69b4b06d
dedaf52f
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
55 additions
and
24 deletions
+55
-24
tools.py
libs/tools.py
+3
-6
product.py
search/utils/product.py
+9
-9
group.py
search/views/group.py
+4
-0
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 @
359b90f6
...
@@ -22,15 +22,13 @@ def tzlc(dt, truncate_to_sec=True):
...
@@ -22,15 +22,13 @@ def tzlc(dt, truncate_to_sec=True):
return
timezone
(
settings
.
TIME_ZONE
)
.
normalize
(
dt
)
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
:
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
)
redis_key
=
"physical:home_recommend"
+
":user_id:"
+
str
(
user_id
)
+
":query_type:"
+
str
(
query_type
)
else
:
else
:
redis_key
=
"physical:home_recommend"
+
":device_id:"
+
str
(
device_id
)
+
":query_type:"
+
str
(
query_type
)
redis_key
=
"physical:home_recommend"
+
":device_id:"
+
str
(
device_id
)
+
":query_type:"
+
str
(
query_type
)
have_read_topic_id_list
=
list
()
have_read_topic_id_list
=
list
()
redis_field_list
=
[
b
'have_read_topic_list'
]
redis_field_list
=
[
b
'have_read_topic_list'
]
redis_field_val_list
=
redis_client
.
hmget
(
redis_key
,
redis_field_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):
...
@@ -40,4 +38,4 @@ def get_have_read_topic_id_list(device_id,user_id,query_type):
return
have_read_topic_id_list
return
have_read_topic_id_list
except
:
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
list
()
return
list
()
\ No newline at end of file
search/utils/product.py
View file @
359b90f6
...
@@ -19,8 +19,8 @@ class ProductUtils(object):
...
@@ -19,8 +19,8 @@ class ProductUtils(object):
def
get_product_sku
(
cls
,
query
=
''
,
offset
=
0
,
size
=
10
,
filters
=
{}):
def
get_product_sku
(
cls
,
query
=
''
,
offset
=
0
,
size
=
10
,
filters
=
{}):
try
:
try
:
multi_fields
=
{
multi_fields
=
{
'cn_name
_pre
'
:
2
,
'cn_name'
:
2
,
'en_name
_pre
'
:
2
,
'en_name'
:
2
,
'alias'
:
2
,
'alias'
:
2
,
'brand_cn_name'
:
2
,
'brand_cn_name'
:
2
,
'brand_en_name'
:
2
,
'brand_en_name'
:
2
,
...
@@ -61,7 +61,7 @@ class ProductUtils(object):
...
@@ -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
)
logging
.
info
(
"get product query:
%
s"
%
q
)
...
@@ -80,9 +80,9 @@ class ProductUtils(object):
...
@@ -80,9 +80,9 @@ class ProductUtils(object):
logging
.
info
(
"get filters:
%
s"
%
filters
)
logging
.
info
(
"get filters:
%
s"
%
filters
)
f
=
[
f
=
[
{
'term'
:
{
"have_image"
:
True
}},
#
{'term': {"have_image": True}},
{
'term'
:
{
"is_online"
:
True
}},
#
{'term': {"is_online": True}},
{
'term'
:
{
"is_deleted"
:
False
}},
{
"term"
:
{
"is_deleted"
:
False
}},
]
]
if
not
filters
:
if
not
filters
:
...
@@ -94,12 +94,12 @@ class ProductUtils(object):
...
@@ -94,12 +94,12 @@ class ProductUtils(object):
continue
continue
if
k
==
"brand"
:
if
k
==
"brand"
:
f
.
append
({
"term"
:
{
"brand_cn_name"
:
v
}})
f
.
append
({
"term"
:
{
"brand_cn_name
_pre
"
:
v
}})
if
k
==
"effect"
:
if
k
==
"effect"
:
f
.
append
({
"term"
:
{
"effect_cn_name"
:
v
}})
f
.
append
({
"term"
:
{
"effect_cn_name
_pre
"
:
v
}})
if
k
==
"category"
:
if
k
==
"category"
:
f
.
append
({
"term"
:
{
"category_cn_name"
:
v
}})
f
.
append
({
"term"
:
{
"category_cn_name
_pre
"
:
v
}})
return
f
return
f
search/views/group.py
View file @
359b90f6
...
@@ -359,6 +359,10 @@ def pictorial_activity_sort(activity_id=0, offset=0, size=10, sort_type=1):
...
@@ -359,6 +359,10 @@ def pictorial_activity_sort(activity_id=0, offset=0, size=10, sort_type=1):
now
=
int
(
time
.
mktime
(
now
.
timetuple
()))
now
=
int
(
time
.
mktime
(
now
.
timetuple
()))
activity_status
=
int
(
time
.
mktime
(
activity_status
.
timetuple
()))
activity_status
=
int
(
time
.
mktime
(
activity_status
.
timetuple
()))
logging
.
info
(
"get now:
%
s"
%
now
)
logging
.
info
(
"get activity_status:
%
s"
%
activity_status
)
pictorial_ids_list
=
[]
pictorial_ids_list
=
[]
if
sort_type
==
1
:
if
sort_type
==
1
:
redis_key
=
"pictorial:activity:vote:id:"
+
str
(
activity_id
)
redis_key
=
"pictorial:activity:vote:id:"
+
str
(
activity_id
)
...
...
trans2es/mapping/product.json
View file @
359b90f6
...
@@ -10,17 +10,27 @@
...
@@ -10,17 +10,27 @@
"update_time_val"
:{
"type"
:
"long"
},
//更新时间
"update_time_val"
:{
"type"
:
"long"
},
//更新时间
"is_deleted"
:{
"type"
:
"boolean"
},
//是否被删除
"is_deleted"
:{
"type"
:
"boolean"
},
//是否被删除
"price"
:{
"type"
:
"double"
},
//价格
"price"
:{
"type"
:
"double"
},
//价格
"cn_name_pre"
:{
"type"
:
"text"
,
"index"
:
"false"
},
//商品名称
"cn_name"
:{
"type"
:
"text"
,
"analyzer"
:
"gm_default_index"
,
"search_analyzer"
:
"gm_default_index"
},
//商品名称
"en_name_pre"
:{
"type"
:
"text"
,
"index"
:
"false"
},
//商品原名
"en_name"
:{
"type"
:
"text"
,
"analyzer"
:
"gm_default_index"
,
"search_analyzer"
:
"gm_default_index"
},
"alias"
:{
"type"
:
"text"
,
"index"
:
"false"
},
"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"
},
"description"
:{
"type"
:
"text"
,
"analyzer"
:
"keyword"
,
"search_analyzer"
:
"keyword"
},
"have_image"
:{
"type"
:
"boolean"
},
"have_image"
:{
"type"
:
"boolean"
},
"comment_nums"
:{
"type"
:
"long"
},
"comment_nums"
:{
"type"
:
"long"
},
"brand_cn_name
"
:{
"type"
:
"text"
,
"index"
:
"false
"
},
//所属品牌名称
"brand_cn_name
_pre"
:{
"type"
:
"text"
,
"analyzer"
:
"keyword
"
},
//所属品牌名称
"brand_en_name
"
:{
"type"
:
"text"
,
"index"
:
"false
"
},
//所属品牌原名
"brand_en_name
_pre"
:{
"type"
:
"text"
,
"analyzer"
:
"keyword
"
},
//所属品牌原名
"brand_alias
"
:{
"type"
:
"text"
,
"index"
:
"false
"
},
//所属品牌别名
"brand_alias
_pre"
:{
"type"
:
"text"
,
"analyzer"
:
"keyword
"
},
//所属品牌别名
"category_cn_name
"
:{
"type"
:
"text"
,
"index"
:
"false
"
},
//所属类目的名称
"category_cn_name
_pre"
:{
"type"
:
"text"
,
"analyzer"
:
"keyword
"
},
//所属类目的名称
"effect_cn_name
"
:{
"type"
:
"text"
,
"index"
:
"false
"
}
//所属功效的名称
"effect_cn_name
_pre"
:{
"type"
:
"text"
,
"analyzer"
:
"keyword
"
}
//所属功效的名称
}
}
}
}
...
...
trans2es/utils/product_transfer.py
View file @
359b90f6
...
@@ -6,6 +6,7 @@ import logging
...
@@ -6,6 +6,7 @@ import logging
import
traceback
import
traceback
import
time
import
time
from
libs.tools
import
tzlc
from
libs.tools
import
tzlc
from
pypinyin
import
lazy_pinyin
class
ProductTransfer
(
object
):
class
ProductTransfer
(
object
):
...
@@ -23,9 +24,18 @@ class ProductTransfer(object):
...
@@ -23,9 +24,18 @@ class ProductTransfer(object):
res
[
"create_time_val"
]
=
int
(
time
.
mktime
(
instance
.
create_time
.
timetuple
()))
res
[
"create_time_val"
]
=
int
(
time
.
mktime
(
instance
.
create_time
.
timetuple
()))
res
[
"update_time_val"
]
=
int
(
time
.
mktime
(
instance
.
update_time
.
timetuple
()))
res
[
"update_time_val"
]
=
int
(
time
.
mktime
(
instance
.
update_time
.
timetuple
()))
res
[
"price"
]
=
instance
.
price
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
[
"cn_name_pre"
]
=
instance
.
cn_name
res
[
"en_name_pre"
]
=
instance
.
en_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
[
'description'
]
=
instance
.
description
res
[
"have_image"
]
=
True
if
instance
.
image
else
False
res
[
"have_image"
]
=
True
if
instance
.
image
else
False
res
[
"comment_nums"
]
=
instance
.
comment_nums
res
[
"comment_nums"
]
=
instance
.
comment_nums
...
@@ -34,22 +44,32 @@ class ProductTransfer(object):
...
@@ -34,22 +44,32 @@ class ProductTransfer(object):
res
[
"brand_cn_name"
]
=
result_name
.
get
(
"cn_name"
,
""
)
res
[
"brand_cn_name"
]
=
result_name
.
get
(
"cn_name"
,
""
)
res
[
"brand_en_name"
]
=
result_name
.
get
(
"en_name"
,
""
)
res
[
"brand_en_name"
]
=
result_name
.
get
(
"en_name"
,
""
)
res
[
"brand_alias"
]
=
result_name
.
get
(
"alias"
,
""
)
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
:
else
:
res
[
"brand_cn_name"
]
=
""
res
[
"brand_cn_name"
]
=
""
res
[
"brand_en_name"
]
=
""
res
[
"brand_en_name"
]
=
""
res
[
"brand_alias"
]
=
""
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
()
category_cn_name
=
instance
.
get_category_en_name
()
if
category_cn_name
:
if
category_cn_name
:
res
[
"category_cn_name"
]
=
category_cn_name
res
[
"category_cn_name"
]
=
category_cn_name
res
[
"category_cn_name_pre"
]
=
category_cn_name
else
:
else
:
res
[
"category_cn_name"
]
=
[]
res
[
"category_cn_name"
]
=
[]
res
[
"category_cn_name_pre"
]
=
[]
effect_cn_name
=
instance
.
get_effect_cn_name
()
effect_cn_name
=
instance
.
get_effect_cn_name
()
if
effect_cn_name
:
if
effect_cn_name
:
res
[
'effect_cn_name'
]
=
effect_cn_name
res
[
'effect_cn_name'
]
=
effect_cn_name
res
[
'effect_cn_name_pre'
]
=
effect_cn_name
else
:
else
:
res
[
"effect_cn_name"
]
=
[]
res
[
"effect_cn_name"
]
=
[]
res
[
"effect_cn_name_pre"
]
=
[]
logging
.
info
(
"get product:
%
s"
%
res
)
logging
.
info
(
"get product:
%
s"
%
res
)
return
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