简体   繁体   English

带有searchkick的聚合

[英]Aggregations with searchkick

I'm trying to get this Aggregations thing working with my search results page. 我正在尝试使“聚合”功能与我的搜索结果页面一起使用。

I'm struggling with this at the moment. 我目前正在为此苦苦挣扎。 So far i do not know what to put into my view. 到目前为止,我不知道该说些什么。

I have this in my controller, 我的控制器中有这个

@events = Event.search params[:search], suggest: true, partial: true, misspellings: {distance: 2}, aggs: [:eventname, :type]

I don't know what to put in the view, I cant seem to find any help for this. 我不知道该说些什么,对此似乎找不到任何帮助。

Also I would like to put a date filter on, So any events that are within a certain date range it would only show these. 我也想设置一个日期过滤器,因此在某个日期范围内的任何事件都只会显示这些内容。

Any help would be much appreciated 任何帮助将非常感激

Sam 山姆

To get searched events 获取搜索事件

@events.to_a

To get events count 获取事件计数

@events.count

To get aggregation result 获得聚合结果

@events.aggs

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM