非泛型字段不能与类型参数一起使用
Non generic type Fields can not be used with type argument
当我尝试将 Source Filter 添加到我的 SearchRequest
时,出现错误
The non generic type 'Fields' can not be used with type arguments
在 Fields
。这是代码片段:
var request = new SearchRequest<ElasticSearchJsonObject.Rootobject>(Nest.Indices.Index("myindex"), Types.All)
{
From = 0,
Size = 10,
Query = query,
Source = new SourceFilter
{
Includes = "*",
Excludes = Fields<ElasticSearchJsonObject.Rootobject>(p => p.footer)
}
};
即使我直接尝试 Fields("footer")
,排除字段中也会出现错误。
这是文档建议的方式。
我正在使用 Elastic Search 6.0.2 和 NEST 6.0.1。
对于Fields
,它支持多种类型的隐式转换,包括
Infer.Fields 例如
Nest.Infer.Fields<ElasticSearchJsonObject.Rootobject>(p => p.footer)
字符串例如
"footer"
System.Reflection.PropertyInfo 例如
typeof(ElasticSearchJsonObject.Rootobject).GetProperty("footer")
本质上是支持多字段的Field
版本。 Check out the documentation on Field
inference.
当我尝试将 Source Filter 添加到我的 SearchRequest
时,出现错误
The non generic type 'Fields' can not be used with type arguments
在 Fields
。这是代码片段:
var request = new SearchRequest<ElasticSearchJsonObject.Rootobject>(Nest.Indices.Index("myindex"), Types.All)
{
From = 0,
Size = 10,
Query = query,
Source = new SourceFilter
{
Includes = "*",
Excludes = Fields<ElasticSearchJsonObject.Rootobject>(p => p.footer)
}
};
即使我直接尝试 Fields("footer")
,排除字段中也会出现错误。
这是文档建议的方式。
我正在使用 Elastic Search 6.0.2 和 NEST 6.0.1。
对于Fields
,它支持多种类型的隐式转换,包括
Infer.Fields 例如
Nest.Infer.Fields<ElasticSearchJsonObject.Rootobject>(p => p.footer)
字符串例如
"footer"
System.Reflection.PropertyInfo 例如
typeof(ElasticSearchJsonObject.Rootobject).GetProperty("footer")
本质上是支持多字段的Field
版本。 Check out the documentation on Field
inference.