Hi Gedeon

I understand that it is a heavy load on the app - unfortunately, Sphinx doesn't 
provide any detailed information on which parts of fields match when performing 
searches. It also has no concept of subobjects - when you have multiple values 
for a single field, they get merged together by SQL into one long string.

One thing that may speed it up is using an :include - TS will just pass this 
through to the underlying #find call to ActiveRecord when instantiating 
objects, which could help with loading the association objects. This isn't 
perfect, though.

-- 
Pat

On 14/05/2010, at 5:20 PM, Gedeon wrote:

> Hi Pat,
> 
> I have one more question here.
> The code you recommended
> (  writeboards.collect(&:writeboard_contents).flatten.collect(&:body).join('
> ') ) is veeeery heavy on the application. It takes forever to load on
> my development machine. Also, doing this means we lose some big
> benefits from the search. ThinkingSphinx must know at some point what
> objects contain the search keyword. Now, it seems I have to retrieve
> all objects (heavy process) then filter them again (another heavy
> process) through excerpts.
> Is there any way of retrieving only the objects Sphinx found in the
> search?
> I realize I could create another ThinkingSphinx search for that, but
> that still doesnt seem to make much sense to me...
> 
> Best regards,
> 
> Gedeon
> 
> On Apr 26, 10:14 am, Gedeon <[email protected]> wrote:
>> I see! Thanks a lot!
>> It's actually a lot easier than I thought :-)
>> 
>> On Apr 23, 1:59 pm, Pat Allan <[email protected]> wrote:
>> 
>> 
>> 
>>> HiGedeon
>> 
>>> You can't delve into associated objects for excerpts directly - but the 
>>> excerpts object just looks at methods, not columns, so just create a method 
>>> that pulls all the association data together, and call that via excerpts 
>>> instead.
>> 
>>>   def wb_content_body
>>>     
>>> writeboards.collect(&:writeboard_contents).flatten.collect(&:body).join(' ')
>>>   end
>> 
>>>   # ...
>> 
>>>   project.excerpts.wb_content_body
>> 
>>> Cheers
>> 
>>> --
>>> Pat
>> 
>>> On 20/04/2010, at 2:10 PM,Gedeonwrote:
>> 
>>>> Hello Pat (and all Thinking Sphinx experts),
>> 
>>>> Sorry to bother you again. I hope this problem will be easy to solve!
>>>> The context is still the same as in my previous thread: Searching
>>>> projects.
>> 
>>>> Projects are linked to several kinds of associated objects.
>>>> One of these are "writeboards" (which can be considered as some kind
>>>> of wiki) and each writeboard can have several "writeboard_contents"
>>>> which are the different versions of the wiki.
>> 
>>>> So:
>>>> A project has many writeboards
>>>> A writeboard has many writeboard_contents
>> 
>>>> My ThinkingSphinx index definition contains:
>>>> indexes writeboards.writeboard_contents.body, :as => :wb_content_body
>> 
>>>> Now, if I search for "blueberry" and that word appears the 'wiki' of
>>>> project called "pie recipes", how can i let the user know why TS
>>>> retrieves "Pie recipes"?
>>>> I would like to use excerpts to display that info, but I cannot seem
>>>> to get it to work.
>>>> The example I found onhttp://freelancing-god.github.com/ts/en/excerpts.html
>>>> only shows excerpts within the searched class (i.e.:
>>>> article.excerpts.body ) but I cannot see any example of excerpts in
>>>> associated objects (i.e.: article.excerpts.author.biography)
>> 
>>>> I tried several possibilities, but none of them worked:
>>>> project.excerpts.wb_content_body :
>>>> undefined method `wb_content_body' for #<Project:0x9737504>
>> 
>>>> project.excerpts.writeboards.writeboard_contents.body
>>>> undefined method `writeboard_contents' for "#&lt;Writeboard:
>>>> 0x9705888&gt;":String
>> 
>>>> Is something like this possible?
>>>> How can I do it?
>> 
>>>> Thanks a lot for your help!
>>>> Best regards,
>> 
>>>> Gedeon
>> 
>>>> --
>>>> 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 
>> 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.
> 

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