标准商品搜索


商品查询商品聚合是两种不同的资源,但是很多业务场景需要同时获取这两种资源,为了减少接口交互次数,提升效率,提供了商品搜索(Search)接口。商品搜索可以同时获取商品和聚合两种资源。
商品搜索中请求参数res标识请求的资源,可取值products、aggregations,products表示商品资源,aggregations表示商品聚合结果。res=products,aggregation表示同时获取商品和商品聚合结果。res不填默认为products。

  1. SKU搜索
  2. SPU搜索
  3. SKU聚合SPU搜索

1. SKU搜索

根据查询条件查询商品SKU信息和SKU聚合信息。

URL HTTP 功能
/search/:adminId GET 返回SKU查询结果和聚合结果

请求参数

参数名 数据类型 可需 描述
res string 选填 搜索资源, 可取值products、aggregations,products表示商品资源,aggregations表示商品聚合结果。res=products,aggregation表示同时获取商品和商品聚合结果。res不填默认为products。
其它参数同SKU查询请求参数 - - -

返回结果

返回结果中"products"字段对应商品搜索结果,"aggregations"字段对应商品聚合结果。

http://192.168.65.222:18082/search/A967550?q=apple&cats=b2c,设备耗材,数码通讯类,电脑/电脑周边&size=1&res=products,aggregations

HTTP 200 OK
Content-Type: application/json
Vary: Accept
Allow: GET

{
    "products": {
        "total": 2,
        "root": [
            {
                "typeId": 3972,
                "updateTime": "2016-04-22T00:05:23+0800",
                "productLine": [
                    2,
                    1
                ],
                "weight": "",
                "spuId": "p65384",
                "adminId": "A967550",
                "standardCateStatus": 0,
                "marketPrice": 0,
                "D2POnSale": false,
                "D2COnSale": false,
                "images": [
                    "967550/a18eb142002ff5a9e837838324805e69.png",
                    "967550/848d72e110e09717ec1c57720d66d307.jpeg",
                    "967550/10b87a7b067c7474d74fe86470f05e2e.jpeg"
                ],
                "P2COnSale": false,
                "specs": [],
                "unit": "部",
                "title": "iPad mini3 WiFi版 MGGT2CH/A 64GB 银色",
                "salePoint": "",
                "addTime": "2015-02-04T13:31:14+0800",
                "top": 0,
                "stdProductId": "p65384",
                "standardParentCatePath": "",
                "costPrice": 3588,
                "type": "通用商品类型",
                "stock": {
                    "status": true,
                    "name": "总量",
                    "stock": 0
                },
                "skuId": "g104434",
                "tags": [],
                "brand": "Apple/苹果",
                "props": [],
                "brandId": 69418,
                "sys": 2,
                "levels": [
                    2,
                    1
                ],
                "fromOwner": 1,
                "proxy": false,
                "productName": "iPad mini3 WiFi版 MGGT2CH/A 64GB 银色",
                "D2PPrepay": false,
                "minStock": -1,
                "onSale": false,
                "minOrderQuantity": 1,
                "shopStatus": 1,
                "skuBn": "J.05.01.0003-1-Z",
                "barCode": "",
                "pointUserId": null,
                "salePrice": 3500.0,
                "creatorId": "A967550",
                "standardCateId": "c00",
                "ownerId": "A967550"
            }
        ]
    },
    "aggregations": {
        "brand": [
            {
                "key": "Apple/苹果",
                "doc_count": 1
            },
            {
                "key": "苹果(APPLE)",
                "doc_count": 1
            }
        ],
        "cats": [
            {
                "childs": [
                    {
                        "childs": [
                            {
                                "childs": [
                                    {
                                        "childs": [],
                                        "key": "电脑/电脑周边",
                                        "doc_count": 2
                                    }
                                ],
                                "key": "数码通讯类",
                                "doc_count": 2
                            }
                        ],
                        "key": "设备耗材",
                        "doc_count": 2
                    }
                ],
                "key": "b2b",
                "doc_count": 2
            },
            {
                "childs": [
                    {
                        "childs": [
                            {
                                "childs": [
                                    {
                                        "childs": [],
                                        "key": "电脑/电脑周边",
                                        "doc_count": 2
                                    }
                                ],
                                "key": "数码通讯类",
                                "doc_count": 2
                            }
                        ],
                        "key": "设备耗材",
                        "doc_count": 2
                    }
                ],
                "key": "b2c",
                "doc_count": 2
            }
        ],
        "props": [
            {
                "childs": [
                    {
                        "key": "全高清屏(1920×1080)",
                        "doc_count": 1
                    }
                ],
                "key": "分辨率",
                "doc_count": 1
            },
            {
                "childs": [
                    {
                        "key": "Intel i5",
                        "doc_count": 1
                    }
                ],
                "key": "处理器",
                "doc_count": 1
            },
            {
                "childs": [
                    {
                        "key": "10.1-12英寸",
                        "doc_count": 1
                    }
                ],
                "key": "尺寸",
                "doc_count": 1
            },
            {
                "childs": [
                    {
                        "key": "集成显卡",
                        "doc_count": 1
                    }
                ],
                "key": "显卡",
                "doc_count": 1
            }
        ]
    }
}

2. SPU搜索

根据查询条件查询商品SPU信息和SPU聚合结果。

URL HTTP 功能
/spu_search/:adminId GET 返回SPU查询和聚合结果

请求参数

SKU搜索参数

返回结果

返回结果中"products"字段对应商品搜索结果,"aggregations"字段对应商品聚合结果。

http://192.168.65.222:18082/spu_search/A967550?q=apple&cats=b2c,设备耗材,数码通讯类,电脑/电脑周边&size=1&res=products,aggregations

HTTP 200 OK
Content-Type: application/json
Vary: Accept
Allow: GET

{
    "products": {
        "total": 2,
        "root": [
            {
                "typeId": 3972,
                "updateTime": "2015-05-06T10:37:19+0800",
                "productLine": [
                    2,
                    1
                ],
                "spuId": "p65384",
                "adminId": "A967550",
                "standardCateStatus": 0,
                "D2POnSale": false,
                "D2COnSale": false,
                "disabled": 1,
                "images": [
                    "967550/a18eb142002ff5a9e837838324805e69.png",
                    "967550/848d72e110e09717ec1c57720d66d307.jpeg",
                    "967550/10b87a7b067c7474d74fe86470f05e2e.jpeg"
                ],
                "P2COnSale": false,
                "unit": "部",
                "standardCateRootName": "",
                "title": "iPad mini3 WiFi版 MGGT2CH/A 64GB 银色",
                "addTime": "2015-05-06T10:37:19+0800",
                "top": 0,
                "stdProductId": "p65384",
                "standardParentCatePath": "",
                "props": [],
                "type": "通用商品类型",
                "bn": "b040400123",
                "stock": {
                    "status": true,
                    "name": "总量",
                    "stock": 0
                },
                "tags": [],
                "brand": "Apple/苹果",
                "brandId": 69418,
                "sys": 2,
                "levels": [
                    1,
                    2
                ],
                "fromOwner": 1,
                "marketable": 0,
                "goods": [
                    {
                        "typeId": 3972,
                        "updateTime": "2016-04-22T00:05:23+0800",
                        "productLine": [
                            2,
                            1
                        ],
                        "weight": "",
                        "spuId": "p65384",
                        "adminId": "A967550",
                        "marketPrice": 0,
                        "D2POnSale": false,
                        "D2COnSale": false,
                        "images": [
                            "967550/a18eb142002ff5a9e837838324805e69.png",
                            "967550/848d72e110e09717ec1c57720d66d307.jpeg",
                            "967550/10b87a7b067c7474d74fe86470f05e2e.jpeg"
                        ],
                        "P2COnSale": false,
                        "specs": [],
                        "unit": "部",
                        "title": "iPad mini3 WiFi版 MGGT2CH/A 64GB 银色",
                        "salePoint": "",
                        "addTime": "2015-02-04T13:31:14+0800",
                        "top": 0,
                        "costPrice": 3588,
                        "type": "通用商品类型",
                        "stock": {
                            "status": true,
                            "name": "总量",
                            "stock": 0
                        },
                        "skuId": "g104434",
                        "brand": "Apple/苹果",
                        "brandId": 69418,
                        "sys": 2,
                        "levels": [
                            2,
                            1
                        ],
                        "proxy": false,
                        "productName": "iPad mini3 WiFi版 MGGT2CH/A 64GB 银色",
                        "D2PPrepay": false,
                        "minStock": -1,
                        "onSale": false,
                        "minOrderQuantity": 1,
                        "shopStatus": 1,
                        "skuBn": "J.05.01.0003-1-Z",
                        "barCode": "",
                        "pointUserId": null,
                        "salePrice": 3500.0
                    }
                ],
                "shopStatus": 1,
                "pointUserId": null,
                "creatorId": "A967550",
                "standardCateId": "c00",
                "ownerId": "A967550"
            }
        ]
    },
    "aggregations": {
        "brand": [
            {
                "key": "Apple/苹果",
                "doc_count": 1
            },
            {
                "key": "苹果(APPLE)",
                "doc_count": 1
            }
        ],
        "cats": [
            {
                "childs": [
                    {
                        "childs": [
                            {
                                "childs": [
                                    {
                                        "childs": [],
                                        "key": "电脑/电脑周边",
                                        "doc_count": 2
                                    }
                                ],
                                "key": "数码通讯类",
                                "doc_count": 2
                            }
                        ],
                        "key": "设备耗材",
                        "doc_count": 2
                    }
                ],
                "key": "b2b",
                "doc_count": 2
            },
            {
                "childs": [
                    {
                        "childs": [
                            {
                                "childs": [
                                    {
                                        "childs": [],
                                        "key": "电脑/电脑周边",
                                        "doc_count": 2
                                    }
                                ],
                                "key": "数码通讯类",
                                "doc_count": 2
                            }
                        ],
                        "key": "设备耗材",
                        "doc_count": 2
                    }
                ],
                "key": "b2c",
                "doc_count": 2
            }
        ],
        "props": [
            {
                "childs": [
                    {
                        "key": "全高清屏(1920×1080)",
                        "doc_count": 1
                    }
                ],
                "key": "分辨率",
                "doc_count": 1
            },
            {
                "childs": [
                    {
                        "key": "Intel i5",
                        "doc_count": 1
                    }
                ],
                "key": "处理器",
                "doc_count": 1
            },
            {
                "childs": [
                    {
                        "key": "10.1-12英寸",
                        "doc_count": 1
                    }
                ],
                "key": "尺寸",
                "doc_count": 1
            },
            {
                "childs": [
                    {
                        "key": "集成显卡",
                        "doc_count": 1
                    }
                ],
                "key": "显卡",
                "doc_count": 1
            }
        ]
    }
}

3. SKU聚合SPU搜索

根据查询条件查询和聚合SKU,但是结果聚合成SPU的方式。详细介绍见:

URL HTTP 功能
/search/:adminId GET 返回SKU查询和聚合结果,SKU查询结果聚合成SPU返回

请求参数

参数名 数据类型 可需 描述
scene string 必填 值为spu_aggs,表示通过SKU聚合出SPU场景
其它参数同SKU搜索请求参数 - - -

参数详细说明

scene参数
SPU搜索SKU聚合SPU搜索都是返回SPU数据结构,它们的区别如下:

返回结果

返回结果中"products"字段对应商品搜索结果,"aggregations"字段对应商品SKU聚合结果。

http://192.168.65.222:18082/search/A967550?q=apple&cats=b2c,设备耗材,数码通讯类,电脑/电脑周边&size=1&res=products,aggregations&scene=spu_aggs

results matching ""

    No results matching ""