Hi Richard I think this may actually be a limitation with clone (it doesn't deep-clone everything the object references). I'm not sure... because with that change, TS is just using Ruby's implementation of clone, it's not doing anything special. http://ruby-doc.org/core-1.8.7/classes/Object.html#M000621
Is there some other way to structure your code to get the same outcome? Is there some overhead you're trying to avoid by using the same search as a base for other searches? -- Pat On 25/02/2010, at 4:14 PM, Richard wrote: > I spoke too soon, although the clone is an ThinkingSphinx search > object it is not a real clone it is the same instance as the original > one so you cannot add options without being applied to the original... > > Cheers > > Richard > > On Feb 25, 10:07 am, Richard <[email protected]> wrote: >> Pat, >> >> Thanks so much for the excellent plugin, I was using the gem but >> switched to the plugin to try your solution, >> >> It worked! Thanks so much! >> >> While I have you there are a couple of rants I have about facets which >> I gave up using due to performance issues (un-needed db requests etc), >> if you could think about these it would be great.. (maybe I should >> move it to a separate thread) >> >> 1. DB calls are made on associations even if you are only calling the >> id >> >> exp I want maker_id facets on the product search (the makers table is >> called even though I only need the ids) >> >> 2. This is probably OK if you can access the extra objects that have >> been called, but I can't see a place to do this through the Face >> class, I monkey patched facet.rb to add this to facet results to be >> able to have this kind of functionality >> >> 3. Rather than calling the facet then adding name_for wouldn't it be >> easier to have a facet flag on the main search method with the facets >> being accessible like results or current page is. This would keep >> functionality like scopes etc >> >> 4. It would be nice for facets to give you decent count information >> for many to many associations >> >> Bar this it is an amazing plugin, thanks for the work >> >> Richard >> >> On Feb 24, 5:54 pm, Pat Allan <[email protected]> wrote: >> >> >> >>> Hi Richard >> >>> I guess this is a bug - I'd not thought of people wanting to clone a search >>> object. Are you using TS as a plugin? If so, can you edit >>> lib/thinking_sphinx/search.rb and add clone to the CoreMethods array near >>> the top of the file, and see if that helps? >> >>> -- >>> Pat >> >>> On 23/02/2010, at 8:22 PM, Richard wrote: >> >>>> Hi, >> >>>> I am wanting to use a separate thinking sphinx object to give me the >>>> list of makers available in a product search, >> >>>> If I start with the following (I want to dry this up rather that >>>> having to repeat the same list of criteria) >> >>>> @products = Product.order_by_price >>>> @makers = @products.clone >>>> RAILS_DEFAULT_LOGGER.debug "Products Type: #[email protected]}" >>>> RAILS_DEFAULT_LOGGER.debug "Makers Type: #[email protected]}" >> >>>> the output I get is >> >>>> Products Type: ThinkingSphinx::Search >>>> Makers Type: Array >> >>>> I want to call a scope on @makers to group the makers but as it is >>>> already become an array I am not able to. >> >>>> Does anyone know how to make a clone? Or have another way of doing >>>> this? Could this be a bug? >> >>>> Many thanks >> >>>> Richard >> >>>> -- >>>> You received this message because you are subscribed to the Google Groups >>>> "Thinking Sphinx" group. >>>> To post to this group, send email to [email protected]. >>>> To unsubscribe from this group, send email to >>>> [email protected]. >>>> For more options, visit this group >>>> athttp://groups.google.com/group/thinking-sphinx?hl=en. > > -- > You received this message because you are subscribed to the Google Groups > "Thinking Sphinx" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/thinking-sphinx?hl=en. > -- You received this message because you are subscribed to the Google Groups "Thinking Sphinx" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/thinking-sphinx?hl=en.
