Now I have another task. I want to include user's phone number in the
index, but only if it was verified. PhoneNumber is associated model.
I tried this:
    indexes phone_numbers(:phone)
    where "(#{PhoneNumber.table_name}.status = 'Verified' OR
#{PhoneNumber.table_name}.status IS NULL)"

but then I figured it doesn't include users who have phone numbers,
but none of them is verified.
Thought I can do it with indexes call, but I don't know how to
explicitly join phone_numbers table.

On Dec 21, 6:56 am, Pat Allan <[email protected]> wrote:
> Hi Alexey
>
> This should be possible, albeit slightly fiddly - if you're using MySQL, you 
> can do the following:
>
>   indexes "IF(email_verified = 1, email, '')", :as => :email
>
> I'm not sure if PostgreSQL has an IF function, so you may need to find 
> something equivalent that does the same job - and I'm presuming here the two 
> columns are email and email_verified - adapt as necessary.
>
> Cheers
>
> --
> Pat
>
> On 21/12/2010, at 2:37 AM, Alexey Ilyichev wrote:
>
> > Hi!
>
> > I need to build an index for users table and I want email to be
> > included only for these users who have verified their email. Is it
> > possible with thinking sphinx?
>
> > --
> > 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 
> > athttp://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