elasticsearch - Elasticsearch 返回不同的属性值
问题描述
我收集了具有属性品牌和 2 个独特价值的产品:
- “超级品牌A”
- “超级品牌B”
ES查询
var response = new ElasticClient().Search<DTO>(s => s
.Index("index")
.Type("type")
.Aggregations(a => a
.Terms("unique", t => t
.Field(f => f.Brand)
//.Field(f => f.Brand.Suffix("keyword"))
.Size(1000)
)
)
);
var brands = (((BucketAggregate)response.Aggregations.First().Value).Items).Cast<KeyedBucket<Object>>().Select(x => x.Key).ToList();
ES 返回 4 个无效值
- “极好的”
- “牌”
- “一个”
- “乙”
我试图通过将 .Suffix("keyword") 添加到字段来强制完整的属性匹配,但随后它返回空列表。如何获得 2 个不同的值?
解决方案
推荐阅读
- r - 如何从两个向量中选择增加的值 - '编织两个向量'
- java - 如何在 java8 中使用 compareTo 对 LinkedLists 进行排序
- java - Hive selectExpression : ( 表达式 | tableAllColumns );])
- amazon-web-services - Alexa 技能控制台返回 null
- ios - UIApplication.shared 可用性的编译时测试?
- eclipse - Bean 属性“empname”不可读或具有无效的 getter 方法:getter 的返回类型是否与 setter 的参数类型匹配?
- bots - 尝试使用 Telegram Bot 删除“left_chat_member”消息
- c# - 在单元测试中模拟 IHttpContextAccessor
- wordpress - 如何仅在自定义帖子类型的单个和存档页面上将脚本和样式排入队列?
- java - JavaFX:设置分页控制按钮的文本