【发布时间】:2020-05-01 15:08:57
【问题描述】:
我正在尝试重现以下在 Kibana 中运行良好的查询:
{
"query": {
"bool": {
"must": [
{
"match": {
"title": "fake"
}
}
],
"filter": {
"term": {
"roleIds": "af54122f-8d99-47e5-9e5a-88659a1229d4"
}
}
}
}
}
这是我在 .NET 中的尝试:
ISearchResponse<T> response = await client.SearchAsync<T>(s => s
.Query(q => q
.Bool(b => b
.Must(m => m
.Match(t => t
.Field(new Field("title"))
.Value("fake") // "Value" is red.
))
.Filter(f => f
.Term(t => t
.Field(new Field("roleIds")).Value(RoleId))) // Value works here.
));
价值在这里不起作用。编译错误是:
Error CS1061 'MatchQueryDescriptor<T>' does not contain a definition for 'Value' and no accessible extension method 'Value' accepting a first argument of type 'MatchQueryDescriptor<T>' could be found (are you missing a using directive or an assembly reference?)
如何写出bool > must > match > title: val的等价物?
【问题讨论】:
标签: elasticsearch .net-core nest