Heh, index works with no errors. But he don't index id_tag fields with .map

пятница, 1 ноября 2013 г., 12:47:47 UTC+6 пользователь Max NudePatch 
написал:
>
> Another question.
> I have custom table logs
> id, id_tag, id_post
>
> And Post table with association
> has_many :logs, :foreign_key => 'id_post'
>
> So when I want to index 'id_tag' fields with normal index it works as 
> expected.
> indexes logs.id_tag, :as => :id_tag
>
> But if I'm using real time index, it returns error while indexing.
>
> undefined method `id_tag' for []
>
> Because Post.logs returns an array.
> So I've changed it to
>
> indexes logs.map(&:id_tag), :as => :id_tag
>
> and now it works smoothly. So the question is: is it a bug? Am I doing 
> right with this trick?
>
>
> четверг, 31 октября 2013 г., 11:11:25 UTC+6 пользователь Max NudePatch 
> написал:
>>
>> I managed this by adding associations in models, and adding to index:
>> has board.id_board, :as => :id_board
>>
>> Thanks for the great support!
>>
>> четверг, 31 октября 2013 г., 10:32:56 UTC+6 пользователь Max NudePatch 
>> написал:
>>>
>>> I've added model. But how do I tell TS about that?
>>>
>>> среда, 30 октября 2013 г., 18:37:25 UTC+6 пользователь Pat Allan написал:
>>>>
>>>> Thinking Sphinx isn't built to work with tables that aren't represented 
>>>> by models, I'm afraid. What you're trying to do is outside the scope of TS 
>>>> supported functionality.
>>>>
>>>> On 30 Oct 2013, at 11:33 pm, Max NudePatch <[email protected]> wrote:
>>>>
>>>> Column type is integer. But there is no model for this table.
>>>> Posts has model.
>>>> But boards doesn't.
>>>> I'm just using Joins like
>>>> SELECT * FROM `posts`
>>>> INNER JOIN `board` ON (`posts`.`id_board` = `board`.`id_board`)
>>>>
>>>> This query I put into index config 
>>>> set_property :sql_query => "QUERY"
>>>>
>>>> среда, 30 октября 2013 г., 18:00:58 UTC+6 пользователь Pat Allan 
>>>> написал:
>>>>>
>>>>> Does id_board exist in the model's table? If so, what's the column 
>>>>> type?
>>>>>
>>>>> On 30 Oct 2013, at 10:53 pm, Max NudePatch <[email protected]> wrote:
>>>>>
>>>>> I want to index data with conditional joining.
>>>>> Table with posts that I want to index has some data in other table 
>>>>> (wich doesn't have model)
>>>>> I used 'sql_query' property to make custom query. And it works well.
>>>>> But I need to add an additional attribute for indexing from other 
>>>>> table.
>>>>> So when I add 'has id_board' to config file, I'm getting 'undefined 
>>>>> method `type' for nil:NilClass' error.
>>>>>
>>>>> Part of trace
>>>>> /home/max/.rvm/gems/ruby-1.9.3-p392/gems/thinking-sphinx-3.0.6/lib/thinking_sphinx/active_record/attribute/type.rb:64:in
>>>>>  
>>>>> `type_from_database'
>>>>> /home/max/.rvm/gems/ruby-1.9.3-p392/gems/thinking-sphinx-3.0.6/lib/thinking_sphinx/active_record/attribute/type.rb:17:in
>>>>>  
>>>>> `type'
>>>>> /home/max/.rvm/gems/ruby-1.9.3-p392/gems/thinking-sphinx-3.0.6/lib/thinking_sphinx/active_record/attribute.rb:4:in
>>>>>  
>>>>> `type'
>>>>>
>>>>> Maybe there is another way to do joins (and let SQLBuilder to 
>>>>> construct query automatically)?
>>>>>
>>>>> -- 
>>>>> You received this message because you are subscribed to the Google 
>>>>> Groups "Thinking Sphinx" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, send 
>>>>> an email to [email protected].
>>>>> To post to this group, send email to [email protected].
>>>>> Visit this group at http://groups.google.com/group/thinking-sphinx.
>>>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>>>
>>>>>
>>>>>
>>>> -- 
>>>> You received this message because you are subscribed to the Google 
>>>> Groups "Thinking Sphinx" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send 
>>>> an email to [email protected].
>>>> To post to this group, send email to [email protected].
>>>> Visit this group at http://groups.google.com/group/thinking-sphinx.
>>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>>
>>>>
>>>>

-- 
You received this message because you are subscribed to the Google Groups 
"Thinking Sphinx" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/thinking-sphinx.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to