I use this use index

 has 'ifnull(`deleted_for_recipient`, `recipient_id`),
ifnull(`deleted_for_sender`, `sender_id`) ', :as => :person_id, :type
=> :multi

--

Best regards,
Sergey Avseyev



On Fri, Sep 11, 2009 at 11:32, Sergey Avseyev <[email protected]> wrote:
> ok, thank you
>
> --
>
> Best regards,
> Sergey Avseyev
>
>
>
> On Thu, Sep 10, 2009 at 20:50, Pat Allan <[email protected]> wrote:
>>
>> Hi Sergey
>>
>> For that kind of logic, you'd need to create a single attribute using
>> SQL, because you can't use ORs across multiple attributes.
>>
>>   has 'SQL STATEMENT GOES HERE', :as => :user_id, :type => :multi
>>
>> The SQL statement would need to merge sender_id and recipient_id
>> together, depending on the deleted_for_* columns being NULL.
>>
>> --
>> Pat
>>
>> On 09/09/2009, at 2:40 PM, Sergey Avseyev wrote:
>>
>>>
>>> Hi all,
>>>
>>> Can I combine filters with thinking_sphinx?
>>> I have messages:
>>>
>>> class Message < ActiveRecord::Base
>>>  belongs_to :sender, :class_name => 'User'
>>>  belongs_to :recipient, :class_name => 'User'
>>>
>>>  define_index do
>>>    indexes :subject, :body
>>>    indexes sender.name, :as => :sender_name
>>>    indexes recipient.name, :as => :recipient_name
>>>
>>>
>>> has
>>>  :recipient_id
>>> , :deleted_for_recipient, :sender_id, :deleted_for_sender
>>>  end
>>> end
>>>
>>> And I want to search messages, which not deleted
>>> 'where (sender_id = ? AND deleted_for_sender is null) OR (recipient_id
>>> = ? AND deleted_for_recipient is null)
>>>
>>> How should it implemented with :with/:with_all?
>>>
>>> >
>>
>>
>> >>
>>
>

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