Closed razvan-sv closed 3 years ago
Figured it out! It seems you have access to @index
inside the define block. @index.delta?
returns what I needed.
So,
ThinkingSphinx::Index.define :abc, with: :active_record, delta: ThinkingSphinx::Deltas::ResqueDelta do
....
has "SELECT `#{model.table_name}`.`id` AS `id`, `some_id` FROM `#{model.table_name}` WHERE `#{model.table_name}`.`delta`= #{@index.delta?}", as: :something, facet: true, type: :integer, multi: true, source: :query
....
end
Glad to know you've found a solution! I guess the one thing I'd note is that given this is an instance variable, I can't guarantee it won't change in future releases. That said: I'm not expecting it to change! I'm not planning any refactoring, and that instance variable has existed for several years now. So it's very likely to remain stable :)
Hi Pat,
I'm currently trying to speed up my indexing time and saw that if we move some heavy joins to
source: :query
it's improving things a lot.We have tables with tens of millions of rows which we need to set them as facet: :true. They're MVA.
How can I access the delta boolean in the index definition to manually set "WHERE model.delta = #{delta?}" ?
Right now the way we have everything set up does the same thing twice for core & delta indexes because I don't have that where condition.
I'm using v3.4.2.
Thank you for ... everything!