JSON 쿼리를 elasticsearch 쿼리로 변환하려고하는데 실패했습니다. 내 쿼리는 데이터 그룹화 (집계)입니다.
{
"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)
)
)
);
가능하면 도와주세요. 미리 감사드립니다.
쿼리는 다음과 같아야합니다.
client.Search<ModelClass>(s => s
.Index("myIndex")
.Type("myType")
.Aggregations(a => a
.Terms("ResultCount", t => t.Field(p => p.Type)
.Aggregations(a1 => a1
.TopHits("myHits", h => h
.Source(d => d
.Includes(fd => fd
.Fields(
f1 => f1.Type,
f2 => f2.Year
)
)
)
)
)
)
)
);
hits
예약 된 키워드이므로 myHits
대신 사용 했습니다. 또한, 당신의 json 쿼리에서 당신이 가지고 include
있어야한다고 생각합니다.includes
편집 :의 항목은 result.Aggs.Terms("ResultCount").Buckets.ToList()
다음 구조를 갖습니다.
{
"key": 2000,
"doc_count": 1,
"myHits": {
"hits": {
"total": 1,
"max_score": 1,
"hits": [
{
"_index": "myIndex",
"_type": "myType",
"_id": "AVupJZbRLWQhMqJPXgXa",
"_score": 1,
"_source": {
"year": 2000,
"type": "some type"
}
}
]
}
}
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다