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
alpha
physical
Commits
7851173c
Commit
7851173c
authored
5 years ago
by
lixiaofang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add
parent
d20d9170
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
83 additions
and
1 deletion
+83
-1
product.py
search/utils/product.py
+50
-0
product.py
search/views/product.py
+32
-0
product.json
trans2es/mapping/product.json
+1
-1
No files found.
search/utils/product.py
0 → 100644
View file @
7851173c
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from
gm_rpcd.all
import
bind
import
logging
import
traceback
import
json
from
libs.cache
import
redis_client
from
libs.es
import
ESPerform
from
search.utils.group
import
GroupUtils
from
search.utils.common
import
GroupSortTypes
from
libs.es
import
ESPerform
from
trans2es.models.pictorial
import
PictorialTopics
def
get_product_sku
(
query
=
''
,
offset
=
0
,
size
=
10
,
sort_type
=
PRODUCT_ORDER_TYPE
.
DEFAULT
,
filters
=
{}):
try
:
multi_fields
=
{
'cn_name_pre'
:
2
,
'en_name_pre'
:
2
,
'alias'
:
2
,
'brand_cn_name'
:
2
,
'brand_en_name'
:
2
,
'brand_alias'
:
2
,
'category_cn_name'
:
2
,
"effect_cn_name"
:
2
}
query_fields
=
[
'^'
.
join
((
k
,
str
(
v
)))
for
(
k
,
v
)
in
multi_fields
.
items
()]
multi_match
=
{
'query'
:
query
,
'type'
:
'cross_fields'
,
'operator'
:
'and'
,
'fields'
:
query_fields
,
}
q
=
[]
if
query
!=
''
:
q
[
"query"
]
=
{
"bool"
:
{
"should"
:
{
"multi_match"
:
multi_match
},
"minimum_should_match"
:
1
}
}
except
:
logging
.
error
(
"catch exception, query_sku:
%
s"
%
traceback
.
format_exc
())
return
[]
This diff is collapsed.
Click to expand it.
search/views/product.py
0 → 100644
View file @
7851173c
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from
gm_rpcd.all
import
bind
import
logging
import
traceback
import
json
from
libs.cache
import
redis_client
from
libs.es
import
ESPerform
from
search.utils.group
import
GroupUtils
from
search.utils.common
import
GroupSortTypes
from
libs.es
import
ESPerform
from
trans2es.models.pictorial
import
PictorialTopics
@bind
(
"physical/search/product_sort"
)
def
pictorial_topic_sort
(
query
=
''
,
offset
=
0
,
size
=
2
,
sort_type
=
PRODUCT_ORDER_TYPE
.
DEFAULT
,
filters
=
{}):
'''
商品sku排序
:param query:
:param offset:
:param size:
:param sort_type:
:param filters:
:return:
'''
try
:
res
=
get_product_sku
(
query
=
query
,
offset
=
offset
,
size
=
size
,
sort_type
=
sort_type
,
filters
=
filters
)
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
{
"pict_pictorial_ids_list"
:
[]}
This diff is collapsed.
Click to expand it.
trans2es/mapping/product.json
View file @
7851173c
{
"dynamic"
:
"strict"
,
"_routing"
:
{
"required"
:
true
},
"_routing"
:
{
"required"
:
true
},
"properties"
:
{
"id"
:{
"type"
:
"long"
},
//id
"is_online"
:{
"type"
:
"boolean"
},
//上线
...
...
This diff is collapsed.
Click to expand it.
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