Hi Pat!
Thank you for all your help so far! The problem is still actual though.

So basically what I want to get is an array where each of the elements 
includes information from both Item and ItemVariation models (Item has_many 
ItemVariations). Generally I can achieve this in ActiveRecord using *left 
join*, but in ThinkingSphinx when I try to use same technic (as shown 
bellow with *joins: 'left join..'*) I fail since I get only first variation 
(first element of the joined table) along with Item.

The idea behind that is to display variations alongside with items on the 
list. And to be able to treat them independently.

Here is the query

*items_found = Item.search params[:q], *
*    :joins => 'left join item_variations iv on iv.item_id=items.id',*
*    :select => 'items.*, iv.id as variation_id'*


So bellow is what I'm getting

*items_found[0]:*
*  id: 1*
*  variation_id: 3434*

*items_found[1]:*
*  id: 2*
*  variation_id: nil*


And here is what I want to get (here Item 1 goes with two variations and 
they come as standalone elements of the array, and both have same item's 
information, but different item variation's information)


items_found[0]:
  id: 1
  variation_id: 3434

items_found[1]:
  id: 1
  variation_id: 9898

items_found[2]:
  id: 2
  variation_id: nil


Please keep in mind that I use TS v2.0.10

Appreciate any advise or thoughts!
Misha

On Monday, 10 November 2014 08:05:26 UTC-3, Pat Allan wrote:
>
> Hi Misha
>
> Sphinx always paginates - there’s no way to turn that off. You can request 
> really large pages though (the default maximum is 1000 records, but that 
> can be modified):
> http://pat.github.io/thinking-sphinx/advanced_config.html#large-result-sets
>
> I’m not sure I quite understand what you’re after, though… if you want the 
> item_variations loaded from the database alongside each item (eager 
> loading), then you can pass through either :joins or :include options 
> nested within the :sql option. Same goes for :select.
> http://pat.github.io/thinking-sphinx/searching.html#advanced
>
> It’s worth noting, though, that Sphinx itself has no concept of joins - 
> there’s no way to tie one index to another.
>
> Does that help? Have I missed something?
>
> — 
> 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 [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.

Reply via email to