抱歉,如果标题不清楚。我想获得两个品牌的结果(假设品牌A和品牌B。我的查询
{ "size":100,
"query": {
"constant_score" : {
"filter" : {
"bool": {
"should": [
{ "term": {"brand": "brandA"} },
{ "term": {"brand": "brandB"} }
]
}
}
}
}
}
我想要这种格式的结果:
{{"brand" : "brandA",
"contentType" : "audiofile",
"expirationDate" : "2100-01-01T00:00:00.000Z",
"pubdate" : "2024-02-26T11:00:00.000Z",
"editorial" : {
"keywords" : [ ]
},
{"brand" : "brandB",
"contentType" : "audiofile",
"expirationDate" : "2100-01-01T00:00:00.000Z",
"pubdate" : "2024-02-26T11:00:00.000Z",
"editorial" : {
"keywords" : [ ]
}}
另外,是否可以对收到的数据数量设置限制。例如,我希望如果收到的总数据为 100,那么品牌 A 应该有 60% 的数据,品牌 B 应该有 40% 的数据
现在已经解决了:)
我在弹性搜索中使用了top_hits。