Hi Siddhant The search method is mixed into ActiveRecord::Base instead of each model that has a search index - this is because with TS v3 there is now nothing in the model that indicates there’s an index definition. This is part of changes in TS v3 that were made for better performance in the development environment (avoiding the behaviour in TS v1/v2 where it would load *all* models to see which ones have Sphinx indices defined on every request).
So, this means it’s best not have search class methods on models. As for the mixing scopes issue - you cannot use ActiveRecord scopes with Sphinx queries, as one is SQL, and the other is SphinxQL (similar, but not identical). I’d recommend using a Sphinx scope instead: http://pat.github.io/thinking-sphinx/scopes.html Hope this helps - let me know if there’s any further questions. Cheers — Pat > On 15 Mar 2015, at 9:17 pm, Siddhant Goel <[email protected]> wrote: > > Hi everyone, > > I'm working on upgrading some legacy rails code, and in the process, also > updated TS from version 2 to 3. After upgrading though, I can't get the > searches to work properly. From the models I have, only one is using Sphinx, > while the others rely on database queries. > > The relevant code looks like the following - > https://gist.github.com/siddhantgoel/2dfb0e7c309a348e733f > > What I find strange is that ActiveRecord::Base.search is always returning a > ThinkingSphinx::Search object, even in the models which don't have an index > defined in app/indices. So in the non-indexed models (contact.rb in this > case), calling the search method throws a ThinkingSphinx::NoIndicesError. And > in applicant.rb, it throws a ThinkingSphinx::MixedScopesError saying "You > cannot search with Sphinx through ActiveRecord scopes". Any ideas? Thanks! > > Siddhant > > -- > 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 [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/thinking-sphinx. > For more options, visit https://groups.google.com/d/optout. -- 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 [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/thinking-sphinx. For more options, visit https://groups.google.com/d/optout.
