Hey Pat,

Yeah, I figured it wouldn't be straightforward, just wanted to know what you
thought. I'll let you know if I work around it.

Thanks,
Marcos

2010/4/8 Pat Allan <[email protected]>

> Hi Marcos
>
> The issue here is that Sphinx only makes strings reliably sortable within a
> given index - and there's an index per model. What you're trying to do would
> work reliably for floats and unsigned integers, but strings are complex.
>
> Essentially, Sphinx grabs all the string values for a given attribute in
> the index, sorts them alphabetically, then stores the index of each string
> in that sorted array - and it's the indexes it sorts by. So, if in one index
> you had the following names:
>  "Alpha"
>  "Beta"
>  "Gamma"
>
> And in the other:
>  "Delta"
>  "Omega"
>  "Zeta"
>
> Then what Sphinx is actually storing is 1, 2 and 3 for each set - and so
> you'll get Alpha, Delta, Beta, Omega, Gamma, Zeta.
>
> So, after all that explanation, I don't really have much in the way of
> workarounds... You could try to create a string to integer MySQL function
> (using the first few letters, perhaps?), and then call that function in a
> SQL snippet:
>
>  has "STRTOINT(name)", :as => :name_sort, :type => :integer
>
> But that's not particularly elegant either.
>
> If you do figure out a way forward, I'd love to hear it.
>
> Cheers
>
> --
> Pat
>
> On 09/04/2010, at 3:23 AM, Marcos Toledo wrote:
>
> > Hi guys,
> >
> > Assuming A.search(:order => :number).map(&:number) returns [1, 2, 3]
> > and B.search(:order => :number).map(&:number) returns [4, 5, 6], I
> > just noticed that ThinkingSphinx.search(:classes => [A, B], :order
> > => :number).map(&:number) returns [1, 4, 2, 5, 3, 6].
> >
> > I wanted the result to be [1, 2, 3, 4, 5, 6] (that means, an
> > aggregated result and not interpolation of singular results).
> >
> > Follows call on real modules on the following gist in case you want to
> > take a look: https://gist.github.com/4a3ff29d79cf12f13ceb
> >
> > Any clues, suggestions or discussions are deeply appreciated.
> >
> > Thanks,
> > Marcos
> >
> > --
> > 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]<thinking-sphinx%[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]<thinking-sphinx%[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.

Reply via email to