gpt4 book ai didi

ruby-on-rails - Elasticsearch 的多方面过滤器

转载 作者:数据小太阳 更新时间:2023-10-29 07:44:14 24 4
gpt4 key购买 nike

如何将多个过滤器应用到刻面(带有轮胎 gem )?我有一个代码:

facet "packages" do
terms :package
facet_filter :terms, producer: [*params[:producer]] if params[:producer].present?
facet_filter :terms, category_id: [*params[:category_id]] if params[:category_id].present?
end

但它似乎只应用最后一个过滤器。但我需要它们。

最佳答案

试试这个

my_filter = []
my_filter << {:terms => {:producer => [*params[:producer]] }} if params[:producer].present?
my_filter << {:terms => { :producer => [*params[:category_id]] }} if params[:category_id].present?

facet "packages" do
terms :package
facet_filter :and, my_filter
end

关于ruby-on-rails - Elasticsearch 的多方面过滤器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14645259/

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