Hi Paul,
Thanks for your reply!
I'm using ThinkingSphinx gem 2.0.10 and all of this seem not working for
me. I cannot even do it as the manual suggests:
ThinkingSphinx.search(
:select => '*, weight() as w', :order => 'w DESC'
)
But I was able to get it like this:
Item.default_sphinx_sorting.search(params[:q],
joins: 'left join item_variations iv on iv.item_id=items.id',
select: %{items.*, iv.picked_at as variation_picked_at,
case when iv.item_photo_id is not null then iv.picked_at else
items.picked_at end as combined_picked_at}
)
Ordering by combined_picked_at doesn't work though, so I was thinking I can
simply use sort_by, but apparently I'm getting only first page (first 20
items) from the search results when sorting. Looks like pagination mess
this up.
Is it possible to somehow convert all found items in array so they could be
sorted and paginated separately?
Thanks in advance!
--
On Monday, 3 November 2014 18:37:00 UTC+2, Misha Slyusarev wrote:
>
> I would like to be able ordering by a calculated field. Which is
> constructed from a field in current table and if it's empty use a field
> from a associated table.
>
> I used to use case when <http://dev.mysql.com/doc/refman/5.0/en/case.html> in
> my regular Rails requests.
>
> items.joins('left join item_variations iv on iv.item_id=items.id').
> select('case when iv.item_photo_id is not null then iv.picked_at else
> items.picked_at end as combined_picked_at')
>
> Now I'm looking for a way to use similar technique in Sphinx. Is it
> possible?
>
--
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.