Hi Steve
I've got a way forward to greatly improve the speed of indexing… unfortunately, it's not going to work within Thinking Sphinx easily right now.
Sphinx has the ability to gather attribute and field values from separate queries - this existed for TS v1/v2 for attributes, and fields was added in TS v3, but the catch is those separate queries don't work for HABTM joins. I'd love to change that, it's just painful from an ActiveRecord perspective because you're not dealing with a model's table as the base, but the HABTM join table.
Here's the configuration for the relevant source that I modified by hand:
https://gist.github.com/pat/6080031
You'll see that the main query is nice and short - and then there's each of the MVA and joined field definitions. If you put this in the generated source definition in config/development.sphinx.conf, and then run the indexer manually (NOT through the rake task, that'll overwrite this):
indexer --config config/development.sphinx.conf --all --rotate
(Remove --rotate if Sphinx isn't running.) You'll see it's pretty damn fast.
Now, ways forward? Well, I'd love to write something for TS v3 that can handle HABTM - it's just a shame that it might need to be pure ARel rather than ActiveRecord-built (which can otherwise help with joins).
But otherwise: switch from HABTM to has_many/has_many :through - make each of the joins an actual model. Then, you can add :source => :query to each of the appropriate field and attribute definitions, and it should generate something pretty much the same.
Hope this provides some clarity at the very least! And also: thanks for the test app, really helped with debugging!
--
Pat
> --
> You received this message because you are subscribed to the Google Groups "Thinking Sphinx" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
thinking-sphi...@googlegroups.com.
> To post to this group, send email to
thinkin...@googlegroups.com.
> Visit this group at
http://groups.google.com/group/thinking-sphinx.
> For more options, visit
https://groups.google.com/groups/opt_out.
>
>