Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
goods
Project
Project
Details
Activity
Releases
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
bp
goods
Commits
88ffb253
Commit
88ffb253
authored
Jul 20, 2021
by
luhongguang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update:es查询功能优化
parent
fe8e4aa5
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
6 deletions
+7
-6
ElasticGoodService.php
application/services/goods/ElasticGoodService.php
+7
-6
No files found.
application/services/goods/ElasticGoodService.php
View file @
88ffb253
...
...
@@ -132,7 +132,6 @@ class ElasticGoodService
$result
[
"count"
]
=
$res
[
"hits"
][
"total"
][
"value"
];
foreach
(
$res
[
"hits"
][
"hits"
]
as
$key
=>
$source
)
{
$result
[
"list"
][
$key
][
"goods_desc_pic_url_list"
]
=
[];
if
(
!
empty
(
$source
[
"_source"
][
"goods_desc_pic_url"
]))
{
$ksyun
=
GoodsService
::
getUrlList
(
$source
[
"_source"
][
"goods_desc_pic_url"
],
200
,
200
);
...
...
@@ -154,7 +153,7 @@ class ElasticGoodService
$result
[
"list"
][
$key
][
"life_account_id"
]
=
$source
[
"_source"
][
"life_account_id"
];
$result
[
"list"
][
$key
][
"life_account_name"
]
=
$source
[
"_source"
][
"life_account_name"
];
$result
[
"list"
][
$key
][
"life_account_icon"
]
=
$source
[
"_source"
][
"life_account_icon"
];
$result
[
"list"
][
$key
][
"distance"
]
=
empty
(
$source
[
"sort"
][
1
])
?
""
:
round
(
$source
[
"sort"
][
1
],
2
)
.
"km"
;
$result
[
"list"
][
$key
][
"distance"
]
=
empty
(
$source
[
"sort"
][
0
])
?
""
:
round
(
$source
[
"sort"
][
0
],
2
)
.
"km"
;
$result
[
"list"
][
$key
][
"update_time"
]
=
$source
[
"_source"
][
"update_time"
];
}
}
...
...
@@ -187,7 +186,7 @@ class ElasticGoodService
[
"price_sort"
=>
"asc"
],
];
$sortInit
=
empty
(
$sortList
[
$sortType
-
1
])
?
$sortList
[
0
]
:
$sortList
[
$sortType
-
1
];
$sortInit
=
isset
(
$sortList
[
$sortType
])
?
$sortList
[
$sortType
]
:
$sortList
[
0
];
$sort
=
array_merge
(
$sortInit
,
$subjectSort
);
$data
=
[
"sort"
=>
$sort
,
...
...
@@ -201,7 +200,7 @@ class ElasticGoodService
],
"order"
=>
"asc"
,
"unit"
=>
"km"
,
"distance_type"
=>
"plane"
,
"distance_type"
=>
"plane"
,
//更快但精度稍差的 plane 计算方法
];
}
return
$data
;
...
...
@@ -232,6 +231,9 @@ class ElasticGoodService
[
"term"
=>
[
"audit_status"
=>
GoodsSku
::
STATUS_PASS
]],
[
"term"
=>
[
"online_status"
=>
GoodsSku
::
ONLINE_STATUS_ONLINE
]],
];
//gte 是大于等于; gt是大于; lte是小于等于; lt是小于
$data
[
"query"
][
"bool"
][
"filter"
][][
"range"
]
=
[
"inventory_rest"
=>
[[
"gt"
=>
0
]]];
if
(
!
empty
(
$searchContent
)
||
(
!
empty
(
$subjectName
)
&&
$subjectName
!=
"本周上新"
))
{
$multiMatch
=
[[
"multi_match"
=>
[
"query"
=>
$searchContent
.
$subjectName
,
...
...
@@ -249,7 +251,7 @@ class ElasticGoodService
}
if
(
!
empty
(
$latitude
)
&&
!
empty
(
$longitude
))
{
$data
[
"query"
][
"bool"
][
"filter"
][
"geo_distance"
]
=
[
$data
[
"query"
][
"bool"
][
"filter"
][
][
"geo_distance"
]
=
[
"distance"
=>
"50km"
,
"shop_location"
=>
[
"lat"
=>
$latitude
,
...
...
@@ -257,7 +259,6 @@ class ElasticGoodService
]
];
}
return
$data
;
}
...
...
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