title: Thinking Sphinx - nested association with boolean field
body: <p>I have <code>Ruby on Rails 4</code> project with <code>Thinking Sphinx 3</code>. I have few models:</p>
  
  <pre><code>class Investment &lt; ActiveRecord::Base
    has_many :investment_parts 
  end
  
  class InvestmentPart &lt; ActiveRecord::Base
    belongs_to :investment
    has_many :check_orders, dependent: :destroy
    has_many :legal_entity_insurance_companies, through: :check_orders, class_name: "LegalEntities::InsuranceCompany"
  end
  
  class CheckOrder &lt; ActiveRecord::Base
    belongs_to :legal_entity_insurance_company, class_name: "LegalEntities::InsuranceCompany"
    belongs_to :investment_part
  end
  </code></pre>
  
  <p>I need to find Investmens by CheckOrders, which have boolean fields <code>approved</code>.</p>
  
  <pre><code>  create_table "check_orders", force: true do |t|
      ...
      t.boolean  "approved", default: false
    end
  </code></pre>
  
  <p>So I tried that: </p>
  
  <pre><code>ThinkingSphinx::Index.define :investment, with: :active_record do
    indexes investment_parts.check_orders.approved, as: :insuranced_investment
  end
  </code></pre>
  
  <p>But search find nothing:</p>
  
  <pre><code>2.0.0p353 :008 &gt; CheckOrder.pluck(:approved)
     (0.6ms)  SELECT "check_orders"."approved" FROM "check_orders"
   =&gt; [true, true, true] 
  2.0.0p353 :009 &gt; Investment.search("", conditions: {insuranced_investment: true})
    Sphinx  Retrying query "SELECT * FROM `investment_core` WHERE MATCH('@insuranced_investment true') AND `sphinx_deleted` = 0 LIMIT 0, 20 OPTION max_matches=50000; SHOW META" after error: Lost connection to MySQL server during query
    Sphinx Query (3.5ms)  SELECT * FROM `investment_core` WHERE MATCH('@insuranced_investment true') AND `sphinx_deleted` = 0 LIMIT 0, 20 OPTION max_matches=50000
    Sphinx  Found 0 results
   =&gt; []
  </code></pre>
  
  <p>So i decided to try attribute filters:</p>
  
  <pre><code>ThinkingSphinx::Index.define :investment, with: :active_record do
    has investment_parts.check_orders.approved, as: :insuranced_investment_attr
  end
  </code></pre>
  
  <p>But it generates error: </p>
  
  <pre><code>$ rake ts:rebuild
  Stopped searchd daemon (pid: 15516).
  Generating configuration to /Projects/my-project/config/development.sphinx.conf
  Sphinx 2.1.4-release (rel21-r4421)
  ...
  using config file '/Projects/my-project/config/development.sphinx.conf'...
  ...
  indexing index 'investment_core'...
  ERROR: source 'investment_core_0': expected attr type ('uint' or 'timestamp' or 'bigint') in sql_attr_multi, got 'bool insuranced_investment_attr from field'.
  ERROR: index 'investment_core': failed to configure some of the sources, will not index.
  ...
  total 15 reads, 0.000 sec, 0.7 kb/call avg, 0.0 msec/call avg
  total 50 writes, 0.000 sec, 0.5 kb/call avg, 0.0 msec/call avg
  Started searchd successfully (pid: 15556).
  </code></pre>
  
  <p>How can i fix that?</p>