Hi Govinda
You *can* reduce that into a single call - but I don't think there's any
equivalent to the FIELD function in SphinxQL, so it would look something like
this:
Image.search(
:star => true,
:conditions => {:category => 'user_images'},
:with => {:client_id => 1, :user_id => 30985},
:sql => {:order => 'FIELD(image_type_id, 169, 174)'}
)
If you're using TS v1/v2, then the :sql => {:order..} option becomes :sql_order
=> 'FIELD…' instead.
Cheers
--
Pat
On 31/07/2013, at 7:52 PM, Govinda Fichtner wrote:
> OK. Found one way to do it. But I am not sure if this is the best way to do
> it... :-)
>
> ids = Image.search_for_ids("", {:star=>true,
> :conditions=>{"category"=>"user_images"}, :with=>{"client_id"=>1,
> "user_id"=>"30985"}}).to_a
> Image.where(:id => ids).order("FIELD(image_type_id, 169, 174)")
>
> So what I think I am doing now is fetch just the ActiveRecord IDs of my
> result set with Thinkingsphinx and fetch the actual ActiveRecord Objects
> separately in the order I need.
>
> What do you think of this solution?
>
> Govinda
>
>
> Am Mittwoch, 31. Juli 2013 11:33:16 UTC+2 schrieb Govinda Fichtner:
> Hello,
>
> does anybody know how you would do something like this with Thinking Sphinx
> Search Query:
>
> SELECT * FROM images WHERE user_id = "30985" ORDER BY FIELD(image_type_id,
> '169, 174');
>
> Cheers,
>
> Govinda
>
> --
> 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/groups/opt_out.
>
>
--
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/groups/opt_out.