假设我的 2 个值是“红方”和“绿圈”,当我使用弹性搜索运行聚合时,我得到 4 个值而不是 2 个,空格分隔?它们是红色,方形,绿色,圆形。有没有办法获得 2 个原始值。
代码如下:
var result = this.client.Search<MyClass>(s => s
.Size(int.MaxValue)
.Aggregations(a => a
.Terms("field1", t => t.Field(k => k.MyField))
)
);
var agBucket = (Bucket)result.Aggregations["field1"];
var myAgg = result.Aggs.Terms("field1");
IList<KeyItem> list = myAgg.Items;
foreach (KeyItem i in list)
{
string data = i.Key;
}