freelancing-god/thinking-sphinx — pull request #349 by cmaion (2012-04-15 15:52:03+00:00)
Title: Can explicitly specify available types for STI tables

Patch for issue 311 (https://github.com/freelancing-god/thinking-sphinx/issues/311).
This introduces a set_sphinx_types method to explicitly define subclasses for Sphinx, and thus avoids having to run "SELECT DISTINCT type FROM table" (which is slow on huge tables when the type columns is not indexed).

class Product < ActiveRecord::Base
set_sphinx_types %w(ProductTypeA ProductTypeB)
define_index do
[...]
end
end