elasticsearch-aggregation - NEST (ElasticSearch) Terms Aggregation does not acknowledge the Query
问题描述
I have a search request as below:
var response = client.Search<ProductElastic>(s => s
.Query(q => q
.Bool(b => b
.Should(mu => mu
.Match(m => m
.Field(f => f.title)
.Boost(1.5)
.Query(inputfilter.q)
), mu => mu
.Match(m => m
.Field(f => f.content)
.Query(inputfilter.q)
)
)
)
)
.Aggregations(a => a
.Terms("doctype_i", he => he
.Field(g => g.doctype_i)
)
.Terms("category_i", e => e
.Field(ge => ge.category_i)
.Size(100)
)
)
);
inputfilter.q
holds the search term. When inputfilter.q
is null it returns all the results and my aggregation bucket numbers are accurately represented. When inputfilter.q
is defined (ex. searching for "test") it refines the results set, however, my aggregation buckets still give me the full numbers as before, as if nothing was searched for. For the record, doctype_i
and category_i
are integer type fields in Elastic.
How do I make my .Aggregations
acknowledge the .Query
so the aggregation buckets reflect numbers based on the results set?
解决方案
推荐阅读
- c# - 强制 Cortana 聆听 - 除了用鼠标点击还有其他方法吗?
- sbt - build.sbt 使用任务更改设置
- python - 在 python 中出现错误为“**系列的真值不明确”
- c# - C# 卡在 StringBuilder 循环中
- php - 在 html 中暴露 id 是否安全
- javascript - jquery show() 关闭面板后不起作用
- javascript - 如何根据点击显示和隐藏内容
- google-chrome-extension - Chrome 扩展运行时 onInstalled 与 onStartup 事件顺序
- javascript - 在 Bing for Mobile 上使用 JavaScript 打开多个选项卡
- postgresql - 如何解决 Ubuntu 18.04 上未安装 Postgresql Client 的错误