首页 > 解决方案 > Elasticsearch 返回不同的属性值

问题描述

我收集了具有属性品牌和 2 个独特价值的产品:

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 个不同的值?

标签: elasticsearchelasticsearch-net

解决方案


推荐阅读