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

How to get grouped facet result from Amazon CloudSearch with structured query

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

当查询请求具有特定品牌(例如本田或马自达)的汽车时,带有品牌和型号方面的信息,则查询将类似于

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
    },
}
]}

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

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

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