0
我想將JSON查詢轉換爲elasticsearch查詢,但我失敗了。 我的查詢是分組數據(聚合)。我試圖有沒有辦法將JSON查詢轉換爲Elasticsearch Nest搜索查詢?
{
"aggs":{
"ResultCount":{
"terms":{
"field":"type"
},
"aggs":{
"hits":{
"top_hits":{
"_source":{
"include":[
"year",
"type"
]
}
}
}
}
}
}
}
代碼:
var result = Client.Search<ModelClass>(s => s
.Index("myIdx")
.Type("myType")
.Aggregations(a => a
.Terms("ResultCount", t => t
.Field(p => p.year)
)
)
);
幫助如果可能的話。先進的謝謝你。
首先非常感謝你爲你的@魯本。仍然沒有獲得慾望的輸出。我有幾個查詢如何獲得這兩個字段在每個桶(組)的聚合。 ? –
你想有2個桶,每個屬性一個。在結果中,您希望看到一個「類型」屬性存儲桶和另一個「年份」存儲桶,只是屬性的分組計數。我對嗎? –
是 'var response = result.Aggs.Terms(「ResultCount」)。Buckets.ToList();' 但在這裏我沒有得到包含類型和年份的桶列表。這實際上是需要的。 –