gpt4 book ai didi

c# - Elasticsearch :从JSON到NEST的查询,没有重复项

转载 作者:行者123 更新时间:2023-12-03 00:59:11 25 4
gpt4 key购买 nike

如何将JSON查询转换为下面的嵌套查询并删除重复项?

{
"size": 30,
"query": {
"multi_match": {
"query": "london",
"operator": "OR",
"fields": [
"name",
"venueTown"
]
}
}
}

最佳答案

您可以稍微简化“汇总”部分,然后将热门广告放入

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)
)
)
);

关于c# - Elasticsearch :从JSON到NEST的查询,没有重复项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40049315/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com