Hi Sabarish

I think you'll need to use the IN function for MVAs:
http://sphinxsearch.com/docs/manual-2.0.1.html#expr-func-in

Try this: "*, IF(global OR IN(role_ids, 5), 1, 0) AS program_global"

Cheers

-- 
Pat

On 01/03/2012, at 4:06 AM, Sabarish Sankar wrote:

> Hi,
> 
> I have a use case where I need to use OR logic with attribute filters. Here 
> is the scenario, User has many roles and has an attribute called global. 
> Below is the index block
> 
> define_index do
>   has roles(:id), :as => :role_ids
>   has global
> end
> 
> And I need to get users with have roles with id 5 or the users  with global 
> true. Here is the query I am trying to use
> 
> User.search(:sphinx_select => "*, IF(global OR role_ids = 5, 1, 0) AS 
> program_global", :with => {'program_global' => true})
> 
> This results in a syntax error -  unexpected TOK_ATTR_MVA near 'role_ids = 5, 
> 1, 0)' . The problem here seems to be that role_ids is a MVA.
> 
> Any help?
> 
> Thank you,
> Sabarish
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Thinking Sphinx" group.
> To view this discussion on the web visit 
> https://groups.google.com/d/msg/thinking-sphinx/-/id94c3zziyYJ.
> 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.


-- 
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