如何使用结构化查询从Amazon CloudSearch获取分组方面结果

时间:2015-03-16 01:52:41

标签: amazon facet amazon-cloudsearch

我正在尝试在以下情况下获取分组方面信息:

当查询请求具有特定品牌(例如HONDA或MAZDA)的汽车时,使用品牌和模型构面信息,然后查询就像

q={or "make":"HONDA" "make":"MAZDA"}&facet.make={}&facet.model={}

然后,它的方面结果如下:

"make" : {
    "buckets" : [{
            "value" : "HONDA",
            "count" : 200
        }, {
            "value" : "MAZDA",
            "count" : 100
        }
    ]
},
"model_display" : {
    "buckets" : [{
        value" : "6",
            "count" : 20
        }, {
            "value" : "2",
            "count" : 30
        },
        {
            "value" : "3",
            "count" : 50
        },
            "value" : "CIVIC",
            "count" : 100
        }, {
            "value" : "ACCORD",
            "count" : 50
        },
        {
            "value" : "CR-V",
            "count" : 50
        },
    }]
}

但是,我真的很想知道是否有任何方法可以获得如下结果:

"model_display" : {
"buckets" : [{
    "HONDA":{
        "value" : "CIVIC",
        "count" : 100
    }, {
        "value" : "ACCORD",
        "count" : 50
    },{
        "value" : "CR-V",
        "count" : 50
    },
},
{
    "MAZDA":{
        "value" : "6",
        "count" : 20
    }, {
        "value" : "2",
        "count" : 30
    },{
        "value" : "3",
        "count" : 50
    },
}
]}

1 个答案:

答案 0 :(得分:1)

执行此操作的唯一方法是使用多个查询,每个查询一次" make":

q=make:'HONDA'&facet.model={}

q=make:'MAZDA'&facet.model={}