Thinking Sphinx can't sort when using delta indexing
I'm not sure who is at fault here, but we have a column in our users table called last_logged_in_at that we use for sorting. This is in a Ra开发者_高级运维ils 2.3 project using Thinking Sphinx with delta indexes enabled.
When a record has delta set to true, it is push to the bottom even if the sorting by last_logged_in_at should put it at the top.
I tried with last_logged_in_at being a datetime, a timestamp and even an integer and the behavior is always the same.
Any ideas why?
The query looks something like:
{:populate=>true,
:match_mode=>:boolean,
:order=>"last_logged_in_at DESC, updated_at DESC",
:per_page=>20,
:with_all=>{:role_id=>17,
:state=>"activated",
:mandator_id=>9,
:profile_active=>true},
:page=>nil}
Sorry, life's crazy busy, hence slow reply.
You're filtering on a string - which Sphinx doesn't currently allow. There are ways around this, though.
Also: You're using :with_all
, but :with
behaves in exactly the same way in your situation. :with_all
is useful when you want to match multiple values on a single attribute. For example, this query will match results where articles have any of the given tag ids:
Article.search :with => {:tag_ids => [1, 2, 3]}
But this next query matches articles with all of the given tag ids:
Article.search :with_all => {:tag_ids => [1, 2, 3]}
I realise neither of these points are directly related to your issue - however, it's best to get the query valid first, and then double-check whether the behaviour is correct or not.
精彩评论