我有一个示例公司JSON文档结构,如下所示:
[
{
"id": "id1","name": "company1","employees": [
{
"name": "employee1","education": "education1"
},{
"name": "employee2","education": "education2"
}
]
}
]
我正在做这样的查询:
GET companies/_search
{
"query": {
"bool": {
"must": [
{
"term": {
"employees.education": {
"value": "education1"
}
}
},{
"term": {
"employees.education": {
"value": "education2"
}
}
}
]
}
}
}
查询是使用nesT构建的:
var filters = new List<Func<QueryContainerDescriptor<Company>,QueryContainer>>();
foreach (var education in educationsToFilter)
{
filters.Add(fq => fq.Term(f => f.Employees.Suffix("education"),education));
}
var searchResponse = _client.Search<Company>(s => s
.Query(q => q
.Bool(bq => bq
.Filter(filters)
)
)
);
是否有更好的方法来查找术语字段而不是使用后缀方法?我想要一种更安全的类型。