Sure, here it is:
has phone_numbers.phone, :as => :phone_any_status
indexes "GROUP_CONCAT(DISTINCT IF(#{PhoneNumber.table_name}.status
= 'Verified', #{PhoneNumber.table_name}.phone, '') SEPARATOR '
')", :as => :phone
I copied it from config generated for
indexes phone_numbers.phone
and changed a little
On Dec 22, 9:57 am, Pat Allan <[email protected]> wrote:
> Hi Alexey
>
> Care to share what that sql fragment/field definition is?
>
> --
> Pat
>
> On 22/12/2010, at 5:29 PM, Alexey Ilyichev wrote:
>
> > After hacking into thinking sphinx source a bit, I finally came out
> > with a dirty solution that describes a field phone_any_status to make
> > TS join phone_numbers table, and describes phone attribute with sql
> > fragment.
>
> > On 21 дек, 10:20, Alexey Ilyichev <[email protected]> wrote:
> >> 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
> > 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.