标准商品查询


商品查询根据指定的查询条件返回符合条件商品,支持分页和排序。

  1. SKU查询
  2. SPU查询
  3. SKU聚合SPU查询

1. SKU查询

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

URL HTTP 功能
/products/:adminId GET 返回SKU搜索结果

请求参数

参数名 数据类型 可需 描述
q string 选填 搜索关键词
basic string 选填 基础查询条件,不同查询条件之间用";"分割,同一查询条件下的值支持多选,用","分割;基础查询条件包括"brand"(品牌)和"price"(价格),其中价格区间采用通行的左闭右开原则,支持多个区间。比如基础查询条件为:品牌为华为或者小米,价格区间为小于1000或者介于1500到2500或者大于4000,格式为:basic=brand:华为,小米;price:-1000,1500-2500,4000-
cats string 选填 商品类目路径,格式为:"b2c,手机,手机数码"
prop string 选填 商品属性,格式同basic参数,为: "网络:移动4g,联通4g;颜色:白色,黑色"
from int 选填 起始商品条数,非分页数,默认为0,最大为6000
size int 选填 查询商品条数,默认为60,最大为200
sort string 选填 对搜索结果进行排序,可不填,默认值为匹配得分降序,即_score:0。1表示升序、0表示降序,支持多个排序字段。格式为:"stock:1;price:0",表示首先按照库存升序,然后按照价格降序对搜索结果进行排序
format string 选填 返回数据的格式,支持json、xml、yaml,默认json;也可以在HTTP header accept参数中指定返回消息格式

参数详细说明

sort参数

  • 字段升降序可以用order()包裹起来,即"price:1"和"price:order(1)"表达的效果是一样的
  • 不同排序字段间可以用";"或者"_"分割,两者效果等同;推荐用";",符合自然语义
  • 支持动态脚本字段排序。假设我们有如下定义:商品的利润=商品的销售价-商品的成本价,现在需要根据商品的利润降序排列,此时可以用scrpt排序字段。"script:script(doc['salePrice'].value-doc['costPrice'].value),order(0),type(number)"。脚本类似于通用脚本语言,doc表示整个商品数据结构,doc['salePrice']表示商品的销售价对象,doc['salePrice'].value表示商品的销售价值
  • 支持地理位置排序。假设在O2O场景中,我们需要查询离我们附近的商店,这些商店需要按照距离远近进行排序,这时我们可以用'geodistance'排序。千米网的经纬度为118.7732,31.981164,则距离千米网的远近排序为:"geodistance:location(118.7732,31.981164),order(1),unit(km),distancetype(sloppy_arc)"

返回结果

http://192.168.65.222:18082/products/A967550?q=apple&from=0&size=2

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

{
    "total": 5,
    "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"
        },
        {
            "typeId": 7211,
            "updateTime": "2016-04-22T00:05:33+0800",
            "productLine": [
                2,
                1
            ],
            "weight": "",
            "spuId": "152749",
            "adminId": "A967550",
            "standardCateStatus": 0,
            "marketPrice": 0,
            "D2POnSale": false,
            "D2COnSale": false,
            "images": [
                "967550/fd73486c27911583a8b42a3cb68d21c3.jpeg",
                "967550/75db6f7536974ac3ccdedd53e9938f9c.jpeg",
                "967550/29f2f50d66514d1ae057f992eb66cc0d.jpeg",
                "967550/2d9e0cc49f441095a84af23718cd324b.jpeg",
                "967550/d9f868bf3e792ff0a23e7de50526eddc.jpeg"
            ],
            "P2COnSale": false,
            "specs": [
                {
                    "specialPropName": "网络",
                    "specialValName": "全网通"
                },
                {
                    "specialPropName": "机身内存ROM",
                    "specialValName": "64GB"
                },
                {
                    "specialPropName": "机身颜色",
                    "specialValName": "银色"
                }
            ],
            "unit": "台",
            "title": "苹果(Apple)iPhone 6 Plus (A1524) 64GB 银色 4G手机 全网通 64GB 银色",
            "salePoint": "",
            "addTime": "2015-05-18T11:39:58+0800",
            "top": 0,
            "stdProductId": "p90146",
            "standardParentCatePath": "",
            "costPrice": 6330.0,
            "type": "手机",
            "stock": {
                "status": true,
                "name": "总量",
                "stock": 0
            },
            "skuId": "g406875",
            "tags": [],
            "brand": "Apple/苹果",
            "props": [
                {
                    "name": "屏幕尺寸",
                    "value": "5.5-5.0英寸"
                },
                {
                    "name": "系统",
                    "value": "苹果(IOS)"
                },
                {
                    "name": "网络模式",
                    "value": "单卡单模"
                },
                {
                    "name": "核心数",
                    "value": "其它"
                },
                {
                    "name": "摄像头",
                    "value": "其它"
                },
                {
                    "name": "运行内存RAM",
                    "value": "其它"
                },
                {
                    "name": "版本",
                    "value": "大陆版"
                }
            ],
            "brandId": 69418,
            "sys": 2,
            "levels": [
                1,
                2
            ],
            "fromOwner": 1,
            "proxy": false,
            "productName": "苹果(Apple)iPhone 6 Plus (A1524) 64GB 银色 4G手机",
            "D2PPrepay": false,
            "minStock": -1,
            "onSale": false,
            "minOrderQuantity": 1,
            "shopStatus": 1,
            "skuBn": "J.05.01.0013-1-Z",
            "barCode": "",
            "pointUserId": null,
            "salePrice": 6332,
            "creatorId": "A967550",
            "standardCateId": "c00",
            "ownerId": "A967550"
        }
    ]
}

2. SPU查询

根据查询条件查询商品SPU信息。

URL HTTP 功能
/spus/:adminId GET 返回SPU搜索结果

请求参数

SKU查询

返回结果

http://192.168.65.222:18082/spus/A967550?q=apple&from=0&size=2

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

{
    "total": 5,
    "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": [
            ],
            "shopStatus": 1,
            "pointUserId": null,
            "creatorId": "A967550",
            "standardCateId": "c00",
            "ownerId": "A967550"
        },
        {
            "typeId": 125766,
            "updateTime": "2015-05-05T13:52:49+0800",
            "productLine": [
                2,
                1
            ],
            "spuId": "p86385",
            "adminId": "A967550",
            "standardCateStatus": 0,
            "D2POnSale": false,
            "D2COnSale": false,
            "disabled": 1,
            "images": [
                "967550/2b9d3058f80bfaabd5b735f6972f7bf0.jpeg",
                "967550/7e9ae4700617b3aae581fc8ff50bc777.jpeg",
                "967550/82693a285b61100c0218a814020f5b38.jpeg"
            ],
            "P2COnSale": false,
            "unit": "台",
            "standardCateRootName": "",
            "title": "苹果 Apple MacBook Air 11.6英寸128GB闪存宽屏笔记本电脑 MJVM2CH/A",
            "addTime": "2015-05-05T13:52:49+0800",
            "top": 0,
            "stdProductId": "p20524522",
            "standardParentCatePath": "",
            "props": [
                {
                    "name": "尺寸",
                    "value": "10.1-12英寸"
                },
                {
                    "name": "处理器",
                    "value": "Intel i5"
                },
                {
                    "name": "显卡",
                    "value": "集成显卡"
                },
                {
                    "name": "分辨率",
                    "value": "全高清屏(1920×1080)"
                }
            ],
            "type": "笔记本新(1453818622195)",
            "bn": "b040500155",
            "stock": {
                "status": true,
                "name": "总量",
                "stock": 0
            },
            "tags": [],
            "brand": "苹果(APPLE)",
            "brandId": 170505,
            "sys": 2,
            "levels": [
                1,
                2
            ],
            "fromOwner": 1,
            "marketable": 0,
            "goods": [
            ],
            "shopStatus": 1,
            "pointUserId": null,
            "creatorId": "A967550",
            "standardCateId": "c00",
            "ownerId": "A967550"
        }
    ]
}

3. SKU聚合SPU查询

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

URL HTTP 功能
/products/:adminId GET 返回SKU搜索结果

请求参数

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

参数详细说明

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

返回结果

http://192.168.65.222:18082/products/A967550?q=apple&from=0&size=2&scene=spu_aggs

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

{
    "total": 5,
    "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,
            "skuList": [
                {
                    "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"
                }
            ],
            "shopStatus": 1,
            "pointUserId": null,
            "creatorId": "A967550",
            "standardCateId": "c00",
            "ownerId": "A967550"
        },
        {
            "typeId": 7211,
            "updateTime": "2015-05-18T11:39:58+0800",
            "productLine": [
                2,
                1
            ],
            "spuId": "152749",
            "adminId": "A967550",
            "standardCateStatus": 0,
            "D2POnSale": false,
            "D2COnSale": false,
            "disabled": 1,
            "images": [
                "967550/fd73486c27911583a8b42a3cb68d21c3.jpeg",
                "967550/75db6f7536974ac3ccdedd53e9938f9c.jpeg",
                "967550/29f2f50d66514d1ae057f992eb66cc0d.jpeg",
                "967550/2d9e0cc49f441095a84af23718cd324b.jpeg",
                "967550/d9f868bf3e792ff0a23e7de50526eddc.jpeg"
            ],
            "P2COnSale": false,
            "unit": "台",
            "standardCateRootName": "",
            "title": "苹果(Apple)iPhone 6 Plus (A1524) 64GB 银色 4G手机",
            "addTime": "2015-05-18T11:39:58+0800",
            "top": 0,
            "stdProductId": "p90146",
            "standardParentCatePath": "",
            "props": [
                {
                    "name": "屏幕尺寸",
                    "value": "5.5-5.0英寸"
                },
                {
                    "name": "系统",
                    "value": "苹果(IOS)"
                },
                {
                    "name": "网络模式",
                    "value": "单卡单模"
                },
                {
                    "name": "核心数",
                    "value": "其它"
                },
                {
                    "name": "摄像头",
                    "value": "其它"
                },
                {
                    "name": "运行内存RAM",
                    "value": "其它"
                },
                {
                    "name": "版本",
                    "value": "大陆版"
                }
            ],
            "type": "手机",
            "bn": "p90146",
            "stock": {
                "status": true,
                "name": "总量",
                "stock": 0
            },
            "tags": [],
            "brand": "Apple/苹果",
            "brandId": 69418,
            "sys": 2,
            "levels": [
                1,
                2
            ],
            "fromOwner": 1,
            "marketable": 0,
            "skuList": [
                {
                    "typeId": 7211,
                    "updateTime": "2016-04-22T00:05:33+0800",
                    "productLine": [
                        2,
                        1
                    ],
                    "weight": "",
                    "spuId": "152749",
                    "adminId": "A967550",
                    "standardCateStatus": 0,
                    "marketPrice": 0,
                    "D2POnSale": false,
                    "D2COnSale": false,
                    "images": [
                        "967550/fd73486c27911583a8b42a3cb68d21c3.jpeg",
                        "967550/75db6f7536974ac3ccdedd53e9938f9c.jpeg",
                        "967550/29f2f50d66514d1ae057f992eb66cc0d.jpeg",
                        "967550/2d9e0cc49f441095a84af23718cd324b.jpeg",
                        "967550/d9f868bf3e792ff0a23e7de50526eddc.jpeg"
                    ],
                    "P2COnSale": false,
                    "specs": [
                        {
                            "specialPropName": "网络",
                            "specialValName": "全网通"
                        },
                        {
                            "specialPropName": "机身内存ROM",
                            "specialValName": "64GB"
                        },
                        {
                            "specialPropName": "机身颜色",
                            "specialValName": "银色"
                        }
                    ],
                    "unit": "台",
                    "title": "苹果(Apple)iPhone 6 Plus (A1524) 64GB 银色 4G手机 全网通 64GB 银色",
                    "salePoint": "",
                    "addTime": "2015-05-18T11:39:58+0800",
                    "top": 0,
                    "stdProductId": "p90146",
                    "standardParentCatePath": "",
                    "costPrice": 6330.0,
                    "type": "手机",
                    "stock": {
                        "status": true,
                        "name": "总量",
                        "stock": 0
                    },
                    "skuId": "g406875",
                    "tags": [],
                    "brand": "Apple/苹果",
                    "props": [
                        {
                            "name": "屏幕尺寸",
                            "value": "5.5-5.0英寸"
                        },
                        {
                            "name": "系统",
                            "value": "苹果(IOS)"
                        },
                        {
                            "name": "网络模式",
                            "value": "单卡单模"
                        },
                        {
                            "name": "核心数",
                            "value": "其它"
                        },
                        {
                            "name": "摄像头",
                            "value": "其它"
                        },
                        {
                            "name": "运行内存RAM",
                            "value": "其它"
                        },
                        {
                            "name": "版本",
                            "value": "大陆版"
                        }
                    ],
                    "brandId": 69418,
                    "sys": 2,
                    "levels": [
                        1,
                        2
                    ],
                    "fromOwner": 1,
                    "proxy": false,
                    "productName": "苹果(Apple)iPhone 6 Plus (A1524) 64GB 银色 4G手机",
                    "D2PPrepay": false,
                    "minStock": -1,
                    "onSale": false,
                    "minOrderQuantity": 1,
                    "shopStatus": 1,
                    "skuBn": "J.05.01.0013-1-Z",
                    "barCode": "",
                    "pointUserId": null,
                    "salePrice": 6332,
                    "creatorId": "A967550",
                    "standardCateId": "c00",
                    "ownerId": "A967550"
                }
            ],
            "shopStatus": 1,
            "pointUserId": null,
            "creatorId": "A967550",
            "standardCateId": "c00",
            "ownerId": "A967550"
        }
    ]
}

results matching ""

    No results matching ""