We just added an with a :source => :query. This is greatly simplified
but it is something like this:
class Lesson < ActiveRecord::Base
define_index do
indexes content
has 'SELECT `lessons`.`id` * 1 + 0 AS `id`, GROUP_CONCAT(DISTINCT
`spaces`.`id` SEPARATOR \',\') AS `space_ids` FROM lessons (a bunch of
joins) GROUP BY
lessons.id ORDER BY NULL',
:as => :admin_space_ids,
:source => :query
end
end
This works great for the normal indexing. But problems come up with
delta indexing. When the delta indexing happens the entire query above
is run. Basically, instead of updating the index for just the lesson
that was saved, it is returning the
spaces.id for all lessons in the
database.
Looking at the .conf file it looks like for the standard SQL the
following is appended when the conf file is generated:
WHERE `lessons`.`id` >= $start AND `lessons`.`id` <= $end AND
`lessons`.`delta` = 1 GROUP BY `lessons`.`id` ORDER BY NULL
This sql is NOT added to the end of a sql_attr_multi attribute with
a :source of :query.
Am I doing something wrong or should ts be adding this sql to the end
of the sql_attr_multi definition?
Thanks for any help you can offer.