退出嵌套过滤器错误的参数

时间:2014-02-23 22:17:00

标签: ruby-on-rails elasticsearch tire

我想进行嵌套过滤。但是返回错误。还有其他过滤方法吗?使用这个真的吗?

错误输出: enter image description here

/ models / series / filter_season方法:

def self.filter_season
    s = Tire.search('myindex', type: 'series') do
      query do
        filtered do
          query do
            all
          end
          filter do
            nested do
              path 'seasons'
              query do
                bool do
                  must do
                    term 'seasons.title', 'season 5'
                  end
                end
              end
            end
          end
        end
      end
    end
    s.results.each do|result|
      puts result.title
    end

映射设置:

  index_name 'myindex'
  mapping do
    indexes :id, type: 'integer'
    indexes :title, type: 'string'
    indexes :seasons, type: 'nested' do
        indexes :id, type: 'integer'
        indexes :title, type: 'string'
    end
  end

1 个答案:

答案 0 :(得分:1)

请在Nested query with filters test integration

问题上查看以下答案

filter方法需要至少一个参数,在你的情况下,它接收0。因此,错误。

希望本文有助于解决您的问题。