Ruby 思考Sphinx-使用或的属性过滤器的多个条件

Ruby 思考Sphinx-使用或的属性过滤器的多个条件,ruby,ruby-on-rails-4,thinking-sphinx,Ruby,Ruby On Rails 4,Thinking Sphinx,我有我的搜索方法,如下所示: class Machine < ActiveRecord::Base def filter_search(params, order_query = 'machines.updated_at desc') ts_query = '' attribute_filters = { order: order_query.gsub(/.*?\./, ''), conditions: {

我有我的搜索方法,如下所示:

class Machine < ActiveRecord::Base
  def filter_search(params, order_query = 'machines.updated_at desc')
      ts_query = ''
      attribute_filters = { order: order_query.gsub(/.*?\./, ''),
                            conditions: {},
                            with: {},
                            limit: 50000,
                            max_matches: Machine::MAX_TS_MATCHES
                          }

      # ... more methods dismissed      

      if params[:currency].present?
        with_null_currency = "*, IF(currency_attr = #{params[:currency]} OR currency_attr = 0, 1, 0) as my_currency"
        attribute_filters[:select] = with_null_currency
        attribute_filters[:with][:my_currency] = 1
      end

      if params[:machine_ad_type_rent] == 'rent' && params[:machine_ad_type_sale].blank?
        with_rent_ad_mask = "*, IF(ad_mask_attr = 1 OR ad_mask_attr = 3, 1, 0) as my_rent_ad_mask"
        attribute_filters[:select] = with_rent_ad_mask
        attribute_filters[:with][:my_rent_ad_mask] = 1
      end

      ids = Machine.search_for_ids(Riddle::Query.escape(ts_query), attribute_filters)
      machines = machines.where(id: ids).order(order_query)
  end
end
但如果我尝试通过这两个参数进行搜索,它将失败:

2.0.0p353 :007 > Machine.filter_search(machine_ad_type_rent: 'rent', currency: 1)
  Sphinx  Retrying query "SELECT *, IF(ad_mask_attr = 1 OR ad_mask_attr = 3, 1, 0) as my_rent_ad_mask FROM `machine_core` WHERE `my_currency` = 1 AND `my_rent_ad_mask` = 1 AND `sphinx_deleted` = 0 ORDER BY `updated_at` desc LIMIT 0, 50000 OPTION max_matches=500000; SHOW META" after error: index machine_core: no such filter attribute 'my_currency' - SELECT *, IF(ad_mask_attr = 1 OR ad_mask_attr = 3, 1, 0) as my_rent_ad_mask FROM `machine_core` WHERE `my_currency` = 1 AND `my_rent_ad_mask` = 1 AND `sphinx_deleted` = 0 ORDER BY `updated_at` desc LIMIT 0, 50000 OPTION max_matches=500000; SHOW META
  Sphinx  Retrying query "SELECT *, IF(ad_mask_attr = 1 OR ad_mask_attr = 3, 1, 0) as my_rent_ad_mask FROM `machine_core` WHERE `my_currency` = 1 AND `my_rent_ad_mask` = 1 AND `sphinx_deleted` = 0 ORDER BY `updated_at` desc LIMIT 0, 50000 OPTION max_matches=500000; SHOW META" after error: index machine_core: no such filter attribute 'my_currency' - SELECT *, IF(ad_mask_attr = 1 OR ad_mask_attr = 3, 1, 0) as my_rent_ad_mask FROM `machine_core` WHERE `my_currency` = 1 AND `my_rent_ad_mask` = 1 AND `sphinx_deleted` = 0 ORDER BY `updated_at` desc LIMIT 0, 50000 OPTION max_matches=500000; SHOW META
  Sphinx Query (16.5ms)  SELECT *, IF(ad_mask_attr = 1 OR ad_mask_attr = 3, 1, 0) as my_rent_ad_mask FROM `machine_core` WHERE `my_currency` = 1 AND `my_rent_ad_mask` = 1 AND `sphinx_deleted` = 0 ORDER BY `updated_at` desc LIMIT 0, 50000 OPTION max_matches=500000
ThinkingSphinx::SphinxError: index machine_core: no such filter attribute 'my_currency' - SELECT *, IF(ad_mask_attr = 1 OR ad_mask_attr = 3, 1, 0) as my_rent_ad_mask FROM `machine_core` WHERE `my_currency` = 1 AND `my_rent_ad_mask` = 1 AND `sphinx_deleted` = 0 ORDER BY `updated_at` desc LIMIT 0, 50000 OPTION max_matches=500000; SHOW META
    from /Users/serj/.rvm/gems/ruby-2.0.0-p353@gearup/gems/thinking-sphinx-3.1.1/lib/thinking_sphinx/connection.rb:91:in `rescue in query'
    from /Users/serj/.rvm/gems/ruby-2.0.0-p353@gearup/gems/thinking-sphinx-3.1.1/lib/thinking_sphinx/connection.rb:94:in `query'
    from /Users/serj/.rvm/gems/ruby-2.0.0-p353@gearup/gems/thinking-sphinx-3.1.1/lib/thinking_sphinx/connection.rb:75:in `query_all'
    from /Users/serj/.rvm/gems/ruby-2.0.0-p353@gearup/gems/thinking-sphinx-3.1.1/lib/thinking_sphinx/search/batch_inquirer.rb:17:in `block in results'
    from /Users/serj/.rvm/gems/ruby-2.0.0-p353@gearup/gems/thinking-sphinx-3.1.1/lib/thinking_sphinx/connection.rb:37:in `block in take'
    from /Users/serj/.rvm/gems/ruby-2.0.0-p353@gearup/gems/innertube-1.1.0/lib/innertube.rb:138:in `take'
    from /Users/serj/.rvm/gems/ruby-2.0.0-p353@gearup/gems/thinking-sphinx-3.1.1/lib/thinking_sphinx/connection.rb:35:in `take'
    from /Users/serj/.rvm/gems/ruby-2.0.0-p353@gearup/gems/thinking-sphinx-3.1.1/lib/thinking_sphinx/search/batch_inquirer.rb:16:in `results'
    from /Users/serj/.rvm/gems/ruby-2.0.0-p353@gearup/gems/thinking-sphinx-3.1.1/lib/thinking_sphinx/middlewares/inquirer.rb:9:in `block in call'
    from /Users/serj/.rvm/gems/ruby-2.0.0-p353@gearup/gems/activesupport-4.1.1/lib/active_support/notifications.rb:159:in `block in instrument'
    from /Users/serj/.rvm/gems/ruby-2.0.0-p353@gearup/gems/activesupport-4.1.1/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
    from /Users/serj/.rvm/gems/ruby-2.0.0-p353@gearup/gems/activesupport-4.1.1/lib/active_support/notifications.rb:159:in `instrument'
    from /Users/serj/.rvm/gems/ruby-2.0.0-p353@gearup/gems/thinking-sphinx-3.1.1/lib/thinking_sphinx/logger.rb:3:in `log'
    from /Users/serj/.rvm/gems/ruby-2.0.0-p353@gearup/gems/thinking-sphinx-3.1.1/lib/thinking_sphinx/middlewares/inquirer.rb:8:in `call'
    from /Users/serj/.rvm/gems/ruby-2.0.0-p353@gearup/gems/thinking-sphinx-3.1.1/lib/thinking_sphinx/middlewares/geographer.rb:11:in `call'
    from /Users/serj/.rvm/gems/ruby-2.0.0-p353@gearup/gems/thinking-sphinx-3.1.1/lib/thinking_sphinx/middlewares/sphinxql.rb:14:in `call'
... 16 levels...
    from /Users/serj/.rvm/gems/ruby-2.0.0-p353@gearup/gems/railties-4.1.1/lib/rails/commands/console.rb:9:in `start'
    from /Users/serj/.rvm/gems/ruby-2.0.0-p353@gearup/gems/railties-4.1.1/lib/rails/commands/commands_tasks.rb:69:in `console'
    from /Users/serj/.rvm/gems/ruby-2.0.0-p353@gearup/gems/railties-4.1.1/lib/rails/commands/commands_tasks.rb:40:in `run_command!'
    from /Users/serj/.rvm/gems/ruby-2.0.0-p353@gearup/gems/railties-4.1.1/lib/rails/commands.rb:17:in `<top (required)>'
    from /Users/serj/.rvm/gems/ruby-2.0.0-p353@gearup/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in `require'
    from /Users/serj/.rvm/gems/ruby-2.0.0-p353@gearup/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in `block in require'
    from /Users/serj/.rvm/gems/ruby-2.0.0-p353@gearup/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:232:in `load_dependency'
    from /Users/serj/.rvm/gems/ruby-2.0.0-p353@gearup/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in `require'
    from /Users/serj/Projects/gearup/bin/rails:8:in `<top (required)>'
    from /Users/serj/.rvm/gems/ruby-2.0.0-p353@gearup/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:241:in `load'
    from /Users/serj/.rvm/gems/ruby-2.0.0-p353@gearup/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:241:in `block in load'
    from /Users/serj/.rvm/gems/ruby-2.0.0-p353@gearup/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:232:in `load_dependency'
    from /Users/serj/.rvm/gems/ruby-2.0.0-p353@gearup/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:241:in `load'
    from /Users/serj/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /Users/serj/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
2.0.0p353:007>机器。过滤器搜索(机器广告类型租金:'rent',货币:1)
Sphinx重试查询“选择*,如果(ad_mask_attr=1或ad_mask_attr=3,1,0)作为我的租金(machine_core)`其中'my_currency`=1、'my_rent_ad_mask`=1和'Sphinx_deleted`=0,则通过'desc LIMIT 0处的'updated_,50000选项最大匹配数=500000;显示META”错误后:索引机器核心:没有这样的过滤属性“我的货币”-选择*,如果(ad_mask_attr=1或ad_mask_attr=3,1,0)作为“机器核心”中的“我的货币”=1和“我的货币”=1和“斯芬克斯”删除”=0,则由“更新的”在“描述限制0”处删除,50000个选项最多匹配=500000;显示元
Sphinx重试查询“选择*,如果(ad_mask_attr=1或ad_mask_attr=3,1,0)作为我的租金(machine_core)`其中'my_currency`=1、'my_rent_ad_mask`=1和'Sphinx_deleted`=0,则通过'desc LIMIT 0处的'updated_,50000选项最大匹配数=500000;显示META”错误后:索引机器核心:没有这样的过滤属性“我的货币”-选择*,如果(ad_mask_attr=1或ad_mask_attr=3,1,0)作为“机器核心”中的“我的货币”=1和“我的货币”=1和“斯芬克斯”删除”=0,则由“更新的”在“描述限制0”处删除,50000个选项最多匹配=500000;显示元
Sphinx查询(16.5ms)选择*,如果(ad_mask_attr=1或ad_mask_attr=3,1,0)作为my_rent_ad_mask,从'machine_core'中选择*,其中'my_currency`=1和'my_rent_ad_mask`=1和'Sphinx_deleted`=0订单,更新后的描述限制为0,50000选项最大匹配数=500000
ThinkingSphinxError:index machine_core:没有这样的过滤属性“我的货币”-选择*,如果(ad_mask_attr=1或ad_mask_attr=3,1,0)作为“机器核心”中的“我的货币”=1和“我的租金_ad_mask”=1和“sphinx_删除”=0,则“更新”的订单数量限制为0,50000个选项最多匹配=500000;显示元
来自/Users/serj/.rvm/gems/ruby-2.0.0-p353@gearup/gems/thinking-sphinx-3.1.1/lib/thinking\u sphinx/connection.rb:91:in“查询中的救援”
来自/Users/serj/.rvm/gems/ruby-2.0.0-p353@gearup/gems/thinking-sphinx-3.1.1/lib/thinking\u sphinx/connection.rb:94:in'query'
来自/Users/serj/.rvm/gems/ruby-2.0.0-p353@gearup/gems/thinking-sphinx-3.1.1/lib/thinking\u-sphinx/connection.rb:75:in'query\u all'
来自/Users/serj/.rvm/gems/ruby-2.0.0-p353@gearup/gems/thinking-sphinx-3.1.1/lib/thinking\u sphinx/search/batch\u inquirer.rb:17:“结果块中”
来自/Users/serj/.rvm/gems/ruby-2.0.0-p353@gearup/gems/thinking-sphinx-3.1.1/lib/thinking\u sphinx/connection.rb:37:in'block in take'
来自/Users/serj/.rvm/gems/ruby-2.0.0-p353@gearup/gems/innertube-1.1.0/lib/innertube.rb:138:in'take'
来自/Users/serj/.rvm/gems/ruby-2.0.0-p353@gearup/gems/thinking-sphinx-3.1.1/lib/thinking\u sphinx/connection.rb:35:in'take'
来自/Users/serj/.rvm/gems/ruby-2.0.0-p353@gearup/gems/thinking-sphinx-3.1.1/lib/thinking\u sphinx/search/batch\u inquirer.rb:16:in'results'
来自/Users/serj/.rvm/gems/ruby-2.0.0-p353@gearup/gems/thinking-sphinx-3.1.1/lib/thinking\u-sphinx/middleware/inquirer.rb:9:in'block in call'
来自/Users/serj/.rvm/gems/ruby-2.0.0-p353@gearup/gems/activesupport-4.1.1/lib/active\u-support/notifications.rb:159:in‘block-in-instrument’
来自/Users/serj/.rvm/gems/ruby-2.0.0-p353@gearup/gems/activesupport-4.1.1/lib/active\u-support/notifications/instrumenter.rb:20:in'instrument'
来自/Users/serj/.rvm/gems/ruby-2.0.0-p353@gearup/gems/activesupport-4.1.1/lib/active\u-support/notifications.rb:159:in'instrument'
来自/Users/serj/.rvm/gems/ruby-2.0.0-p353@gearup/gems/thinking-sphinx-3.1.1/lib/thinking\u sphinx/logger.rb:3:in'log'
来自/Users/serj/.rvm/gems/ruby-2.0.0-p353@gearup/gems/thinking-sphinx-3.1.1/lib/thinking\u sphinx/middleware/inquirer.rb:8:in'call'
来自/Users/serj/.rvm/gems/ruby-2.0.0-p353@gearup/gems/thinking-sphinx-3.1.1/lib/thinking\u sphinx/middleware/geographer.rb:11:in'call'
来自/Users/serj/.rvm/gems/ruby-2.0.0-p353@gearup/gems/thinking-sphinx-3.1.1/lib/thinking_-sphinx/middleware/sphinxql.rb:14:in'call'
... 16级。。。
来自/Users/serj/.rvm/gems/ruby-2.0.0-p353@gearup/gems/railties-4.1.1/lib/rails/commands/console.rb:9:in'start'
来自/Users/serj/.rvm/gems/ruby-2.0.0-p353@gearup/gems/railties-4.1.1/lib/rails/commands/commands\u tasks.rb:69:in'console'
来自/Users/serj/.rvm/gems/ruby-2.0.0-p353@gearup/gems/railties-4.1.1/lib/rails/commands/commands\u tasks.rb:40:in'run\u command!'
来自/Users/serj/.rvm/gems/ruby-2.0.0-p353@gearup/gems/railties-4.1.1/lib/rails/commands.rb:17:in`'
来自/Users/serj/.rvm/gems/ruby-2.0.0-p353@gearup/gems/activesupport-4.1.1/lib/active\u-support/dependencies.rb:247:in'require'
来自/Users/serj/.rvm/gems/ruby-2.0.0-p353@gearup/gems/activesupport-4.1.1/lib/active\u support/dependencies.rb:247:in'block in require'
来自/Users/serj/.rvm/gems/ruby-2.0.0-p353@gearup/gems/activesupport-4.1.1/lib/active\u-support/dependencies.rb:232:in'load\u-dependency'
来自/Users/serj/.rvm/gems/ruby-2.0.0-p353@gearup/gems/activesupport-4.1.1/lib/active\u-support/dependencies.rb:247:in'require'
from/Users/serj/Projects/gearup/bin/rails:8:in`'
来自/Users/serj/.rvm/gems/ruby-2.0.0-p353@gearup/gems/activesupport-4.1.1/lib/active\u-support/dependencies.rb:241:in'load'
来自/Users/serj/.rvm/gems/ruby-2.0.0-p353@gearup/gems/activesupport-4.1.1/lib/active\u support/dependencies.rb:241:in'block in load'
来自/Users/serj/.rvm/gems/ruby-2.0.0-p353@gearup/gems/activesupport-4.1.1/lib/active\u-support/dependencies.rb:232:in'load\u-dependency'
来自/Users/serj/.rvm/gems/ruby-2.0.0-p353@gearup/gems/activesupport-4.1.1/lib/active\u-support/dependencies.rb:241:in'load'
来自/Users/serj/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/site\u ruby/2.0.0/rubygems/core\u ext/kernel\u require.rb:55:
2.0.0p353 :007 > Machine.filter_search(machine_ad_type_rent: 'rent', currency: 1)
  Sphinx  Retrying query "SELECT *, IF(ad_mask_attr = 1 OR ad_mask_attr = 3, 1, 0) as my_rent_ad_mask FROM `machine_core` WHERE `my_currency` = 1 AND `my_rent_ad_mask` = 1 AND `sphinx_deleted` = 0 ORDER BY `updated_at` desc LIMIT 0, 50000 OPTION max_matches=500000; SHOW META" after error: index machine_core: no such filter attribute 'my_currency' - SELECT *, IF(ad_mask_attr = 1 OR ad_mask_attr = 3, 1, 0) as my_rent_ad_mask FROM `machine_core` WHERE `my_currency` = 1 AND `my_rent_ad_mask` = 1 AND `sphinx_deleted` = 0 ORDER BY `updated_at` desc LIMIT 0, 50000 OPTION max_matches=500000; SHOW META
  Sphinx  Retrying query "SELECT *, IF(ad_mask_attr = 1 OR ad_mask_attr = 3, 1, 0) as my_rent_ad_mask FROM `machine_core` WHERE `my_currency` = 1 AND `my_rent_ad_mask` = 1 AND `sphinx_deleted` = 0 ORDER BY `updated_at` desc LIMIT 0, 50000 OPTION max_matches=500000; SHOW META" after error: index machine_core: no such filter attribute 'my_currency' - SELECT *, IF(ad_mask_attr = 1 OR ad_mask_attr = 3, 1, 0) as my_rent_ad_mask FROM `machine_core` WHERE `my_currency` = 1 AND `my_rent_ad_mask` = 1 AND `sphinx_deleted` = 0 ORDER BY `updated_at` desc LIMIT 0, 50000 OPTION max_matches=500000; SHOW META
  Sphinx Query (16.5ms)  SELECT *, IF(ad_mask_attr = 1 OR ad_mask_attr = 3, 1, 0) as my_rent_ad_mask FROM `machine_core` WHERE `my_currency` = 1 AND `my_rent_ad_mask` = 1 AND `sphinx_deleted` = 0 ORDER BY `updated_at` desc LIMIT 0, 50000 OPTION max_matches=500000
ThinkingSphinx::SphinxError: index machine_core: no such filter attribute 'my_currency' - SELECT *, IF(ad_mask_attr = 1 OR ad_mask_attr = 3, 1, 0) as my_rent_ad_mask FROM `machine_core` WHERE `my_currency` = 1 AND `my_rent_ad_mask` = 1 AND `sphinx_deleted` = 0 ORDER BY `updated_at` desc LIMIT 0, 50000 OPTION max_matches=500000; SHOW META
    from /Users/serj/.rvm/gems/ruby-2.0.0-p353@gearup/gems/thinking-sphinx-3.1.1/lib/thinking_sphinx/connection.rb:91:in `rescue in query'
    from /Users/serj/.rvm/gems/ruby-2.0.0-p353@gearup/gems/thinking-sphinx-3.1.1/lib/thinking_sphinx/connection.rb:94:in `query'
    from /Users/serj/.rvm/gems/ruby-2.0.0-p353@gearup/gems/thinking-sphinx-3.1.1/lib/thinking_sphinx/connection.rb:75:in `query_all'
    from /Users/serj/.rvm/gems/ruby-2.0.0-p353@gearup/gems/thinking-sphinx-3.1.1/lib/thinking_sphinx/search/batch_inquirer.rb:17:in `block in results'
    from /Users/serj/.rvm/gems/ruby-2.0.0-p353@gearup/gems/thinking-sphinx-3.1.1/lib/thinking_sphinx/connection.rb:37:in `block in take'
    from /Users/serj/.rvm/gems/ruby-2.0.0-p353@gearup/gems/innertube-1.1.0/lib/innertube.rb:138:in `take'
    from /Users/serj/.rvm/gems/ruby-2.0.0-p353@gearup/gems/thinking-sphinx-3.1.1/lib/thinking_sphinx/connection.rb:35:in `take'
    from /Users/serj/.rvm/gems/ruby-2.0.0-p353@gearup/gems/thinking-sphinx-3.1.1/lib/thinking_sphinx/search/batch_inquirer.rb:16:in `results'
    from /Users/serj/.rvm/gems/ruby-2.0.0-p353@gearup/gems/thinking-sphinx-3.1.1/lib/thinking_sphinx/middlewares/inquirer.rb:9:in `block in call'
    from /Users/serj/.rvm/gems/ruby-2.0.0-p353@gearup/gems/activesupport-4.1.1/lib/active_support/notifications.rb:159:in `block in instrument'
    from /Users/serj/.rvm/gems/ruby-2.0.0-p353@gearup/gems/activesupport-4.1.1/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
    from /Users/serj/.rvm/gems/ruby-2.0.0-p353@gearup/gems/activesupport-4.1.1/lib/active_support/notifications.rb:159:in `instrument'
    from /Users/serj/.rvm/gems/ruby-2.0.0-p353@gearup/gems/thinking-sphinx-3.1.1/lib/thinking_sphinx/logger.rb:3:in `log'
    from /Users/serj/.rvm/gems/ruby-2.0.0-p353@gearup/gems/thinking-sphinx-3.1.1/lib/thinking_sphinx/middlewares/inquirer.rb:8:in `call'
    from /Users/serj/.rvm/gems/ruby-2.0.0-p353@gearup/gems/thinking-sphinx-3.1.1/lib/thinking_sphinx/middlewares/geographer.rb:11:in `call'
    from /Users/serj/.rvm/gems/ruby-2.0.0-p353@gearup/gems/thinking-sphinx-3.1.1/lib/thinking_sphinx/middlewares/sphinxql.rb:14:in `call'
... 16 levels...
    from /Users/serj/.rvm/gems/ruby-2.0.0-p353@gearup/gems/railties-4.1.1/lib/rails/commands/console.rb:9:in `start'
    from /Users/serj/.rvm/gems/ruby-2.0.0-p353@gearup/gems/railties-4.1.1/lib/rails/commands/commands_tasks.rb:69:in `console'
    from /Users/serj/.rvm/gems/ruby-2.0.0-p353@gearup/gems/railties-4.1.1/lib/rails/commands/commands_tasks.rb:40:in `run_command!'
    from /Users/serj/.rvm/gems/ruby-2.0.0-p353@gearup/gems/railties-4.1.1/lib/rails/commands.rb:17:in `<top (required)>'
    from /Users/serj/.rvm/gems/ruby-2.0.0-p353@gearup/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in `require'
    from /Users/serj/.rvm/gems/ruby-2.0.0-p353@gearup/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in `block in require'
    from /Users/serj/.rvm/gems/ruby-2.0.0-p353@gearup/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:232:in `load_dependency'
    from /Users/serj/.rvm/gems/ruby-2.0.0-p353@gearup/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in `require'
    from /Users/serj/Projects/gearup/bin/rails:8:in `<top (required)>'
    from /Users/serj/.rvm/gems/ruby-2.0.0-p353@gearup/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:241:in `load'
    from /Users/serj/.rvm/gems/ruby-2.0.0-p353@gearup/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:241:in `block in load'
    from /Users/serj/.rvm/gems/ruby-2.0.0-p353@gearup/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:232:in `load_dependency'
    from /Users/serj/.rvm/gems/ruby-2.0.0-p353@gearup/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:241:in `load'
    from /Users/serj/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /Users/serj/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
select = ['*']

if params[:currency].present?
  select << "IF(currency_attr = #{params[:currency]} OR currency_attr = 0, 1, 0) as my_currency"
  attribute_filters[:with][:my_currency] = 1
end

if params[:machine_ad_type_rent] == 'rent' && params[:machine_ad_type_sale].blank?
  select << "IF(ad_mask_attr = 1 OR ad_mask_attr = 3, 1, 0) as my_rent_ad_mask"
  attribute_filters[:with][:my_rent_ad_mask] = 1
end

attribute_filters[:select] = select.join(', ')

ids = Machine.search_for_ids(Riddle::Query.escape(ts_query), attribute_filters)