伙计们我想编写嵌套查询,它将使用过滤器获取不同的结果。
我想在c#中使用Elasticsearch
编写Nest
部分代码。
GET /index/type/_search
{
"query": {
"bool": {
"must": [
{
"terms": {
"ID": [ "5","6" ]
}
},
{
"terms": {
"ProjectID": [ "54"]
}
}
]
}
},
"aggs": {
"my_fields": {
"terms": {
"field": "ID",
"size": 0
}
}
}
}
我是Elasticsearch的新手。请帮我在lambda表达式中编写它。我写了一些代码,但不知道如何在查询中添加方括号
var ElasticSearchNetQuery = new { aggs = new { distinctRespId = new { cardinality = new { field = "RespID" }, query = new { @bool = new { must= new { } } } }, size = 10000 } };
答案 0 :(得分:1)
var results = client.Search<object>(sd => sd
.Index("<index name>")
.Type("<type name>")
.Query(q => q
.Bool(b => b
.Must(
m => m.Terms("ID", new[] { "5", "6" }),
m => m.Terms("ProjectID", new[] { "54" }))))
.Aggregations(a => a
.Terms("my_fields", t => t
.Field("ID")
.Size(0)));