【发布时间】:2016-05-22 09:17:44
【问题描述】:
伙计们,我想编写将使用过滤器获取不同结果的嵌套查询。
我想使用Nest 在c# 中写下Elasticsearch 代码的一部分。
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 } };
【问题讨论】:
-
JSON
[ "5", "6"]在 C# 中可以翻译为:new[] { "5", "6" }。是你要找的吗? -
哦,朋友,我做了一些更改,它起作用了,但它不允许我在 new[] 术语中放入不同的词,例如 ID 和 ProjectID,出现编译时错误 var ElasticSearchNetQuery = new { aggs = new { distinctRespId = new { cardinality = new { field = "RespID" }, query = new { @bool = new { must = new[] { new { terms = new { QID = "" } }, new { terms = new { ProjectID = "" } } } } } } }, 大小 = 10000 };
标签: elasticsearch lambda nest elasticsearch-plugin