Elastic Search:JSON 到无重复的 NEST 查询
Elastic Search: JSON to NEST query without duplicates
如何将 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)
)
)
);
如何将 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)
)
)
);