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
fc8a63b9
Commit
fc8a63b9
authored
Jun 28, 2021
by
luhongguang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update:调试es查询
parent
df468118
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
12 deletions
+26
-12
GoodsToEs.php
application/modules/Cli/controllers/GoodsToEs.php
+1
-1
ElasticGoodService.php
application/services/goods/ElasticGoodService.php
+25
-11
No files found.
application/modules/Cli/controllers/GoodsToEs.php
View file @
fc8a63b9
...
...
@@ -71,7 +71,7 @@ class GoodsToEsController extends Cli
$subShopList
=
ShopService
::
getRelationShop
(
$goodsSkuId
);
$data
=
[
"id"
=>
$goodsSkuInfo
[
"goods_sku_id"
],
"
goods_sku_
id"
=>
$goodsSkuInfo
[
"goods_sku_id"
],
"goods_desc_pic_url"
=>
$goodsSkuInfo
[
"desc_pic_url"
],
"goods_name"
=>
$goodsSkuInfo
[
"goods_name"
],
"inventory_rest"
=>
$goodsSkuInfo
[
"inventory_rest"
],
...
...
application/services/goods/ElasticGoodService.php
View file @
fc8a63b9
...
...
@@ -4,6 +4,7 @@ namespace App\Services\goods;
use
Api\PhpUtils\Common\BaseConvert
;
use
Api\PhpUtils\Elastic\ElasticUtil
;
use
App\Models\goods\mysql\GoodsSku
;
class
ElasticGoodService
{
...
...
@@ -15,9 +16,9 @@ class ElasticGoodService
$data
=
[
"settings"
=>
[
"analysis"
=>
[
"analyzer"
=>
[
"default"
=>
[
"type"
=>
"ik_max_word"
,
"analyzer"
=>
[
"default"
=>
[
"type"
=>
"ik_max_word"
,
]
]
]
...
...
@@ -128,14 +129,22 @@ class ElasticGoodService
"from"
=>
$from
,
"size"
=>
$size
,
"sort"
=>
$sortList
[
$sortType
],
// "query" => [
// "bool" => [
// "must" => [
// ["term" => ["audit_status" => GoodsSku::STATUS_PASS]],
// ["term" => ["online_status" => GoodsSku::ONLINE_STATUS_ONLINE]],
// ],
// ]
// ],
];
if
(
!
empty
(
$params
[
"search_content"
]))
{
$data
[
"query"
]
=
[
"multi_match"
=>
[
$data
[
"query"
]
[
"multi_match"
]
=
[
"query"
=>
$params
[
"search_content"
],
"fields"
=>
[
"
name"
,
"category_1_name"
,
"category_2_name"
,
"desc
"
],
]
]
;
"fields"
=>
[
"
goods_name"
,
"category_1_name"
,
"category_2_name"
,
"desc"
,
"life_account_name"
,
"shop_name
"
],
];
}
$elasticClient
=
ElasticUtil
::
getInstance
();
$res
=
$elasticClient
->
searchDoc
(
self
::
INDEX
,
$data
);
...
...
@@ -143,15 +152,20 @@ class ElasticGoodService
if
(
!
empty
(
$res
[
"hits"
][
"total"
][
"value"
]))
{
$result
[
"count"
]
=
$res
[
"hits"
][
"total"
][
"value"
];
foreach
(
$res
[
"hits"
][
"hits"
]
as
$key
=>
$source
)
{
$result
[
"list"
][
$key
][
"
id"
]
=
BaseConvert
::
decToOther
(
$source
[
"_source"
][
"id"
])
;
$result
[
"list"
][
$key
][
"goods_
pic"
]
=
$source
[
"_source"
][
"goods_pic
"
];
$result
[
"list"
][
$key
][
"
name"
]
=
$source
[
"_source"
][
"
name"
];
$result
[
"list"
][
$key
][
"
goods_sku_id"
]
=
$source
[
"_source"
][
"goods_sku_id"
]
;
$result
[
"list"
][
$key
][
"goods_
desc_pic_url"
]
=
$source
[
"_source"
][
"goods_desc_pic_url
"
];
$result
[
"list"
][
$key
][
"
goods_name"
]
=
$source
[
"_source"
][
"goods_
name"
];
$result
[
"list"
][
$key
][
"inventory_rest"
]
=
$source
[
"_source"
][
"inventory_rest"
];
$result
[
"list"
][
$key
][
"total_amount_sold"
]
=
$source
[
"_source"
][
"total_amount_sold"
];
$result
[
"list"
][
$key
][
"original_price"
]
=
$source
[
"_source"
][
"original_price"
];
$result
[
"list"
][
$key
][
"price"
]
=
$source
[
"_source"
][
"price"
];
$result
[
"list"
][
$key
][
"
status"
]
=
$source
[
"_source"
][
"
status"
];
$result
[
"list"
][
$key
][
"
audit_status"
]
=
$source
[
"_source"
][
"audit_
status"
];
$result
[
"list"
][
$key
][
"online_status"
]
=
$source
[
"_source"
][
"online_status"
];
$result
[
"list"
][
$key
][
"shop_name"
]
=
$source
[
"_source"
][
"shop_name"
];
$result
[
"list"
][
$key
][
"shop_longitude"
]
=
$source
[
"_source"
][
"shop_longitude"
];
$result
[
"list"
][
$key
][
"shop_latitude"
]
=
$source
[
"_source"
][
"shop_latitude"
];
$result
[
"list"
][
$key
][
"life_account_name"
]
=
$source
[
"_source"
][
"life_account_name"
];
$result
[
"list"
][
$key
][
"life_account_icon"
]
=
$source
[
"_source"
][
"life_account_icon"
];
}
}
//为避免空数据时候返回给前端错误结构
...
...
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