我在下面写了 ES Query for fetching data Using filter and Must:我只能使用 ElasticSearch V5 来编写查询。
{
"bool" : {
"must" : [
{
"term" : {
"Name" : {
"value" : "Self",
"boost" : 1.0
}
}
}
],
"filter" : [
{
"terms" : {
"Number" : [
"111",
"222"
]
}
}
]
}
}
我得到这样的输出,具有重复值。我想使用聚合查询。
"hits": [
{ "Name": "Self","Number": 111},
{ "Name": "Self","Number": 222},
{ "Name": "Self","Number": 222},
{ "Name": "Self","Number": 111}
]
我只想为每个数字选择前 1 个值,所以我的结果会更少。
O/P 应该是:
"hits": [
{ "Name": "Self","Number": 222},
{ "Name": "Self","Number": 111}
]