如何将json查询转换为下面的嵌套查询并删除重复项?
{
"size": 30,
"query": {
"multi_match": {
"query": "london",
"operator": "OR",
"fields": [
"name",
"venueTown"
]
}
}
}
答案 0 :(得分:2)
您可以稍微简化聚合部分,并将最热门的匹配放在
中var searchResult = client.Search<SearchResult>(request => request
// Your existing query below...
//.Query(q => q)
.Size(0)
.Aggregations(a => a
// simplify the terms aggregation
.Terms("query", tr => tr
.Field("name")
.Size(30)
)
// Add the top hits aggregation
.TopHits("top", th => th
.Size(1)
)
)
);