我对 Elastic Search 和我在 C# 中使用的 Elastic Search API 很陌生:PlainElastic.Net。
我有一个简单的请求,但我坚持下去:如何在我的查询构建器中添加多个(非硬编码)方面?
//code has been simplified
//list of fields I want to be added in my facet part of the querybuilder
List<string> FacetFields = new List<string>{"field1", "field2", "fieldN"};
//qb is already instantiated with a simple ES query
//I want now to add facets definition
qb.Facets(_facets =>
FacetFields.ForEach(_ff =>
_facets.Terms(t => t
.FacetName("FacetsFor" + _ff)
.Field(_ff)
);
});
);
这不编译,错误是:
无法将 lambda 表达式转换为委托类型“
System.Func<PlainElastic.Net.Queries.Facets<MyType>,PlainElastic.Net.Queries.Facets<MyType>>
”,因为块的某些返回类型不能隐式转换为返回类型委托