Hi Alex

I think your two options are:
* index questions to include answer data, but only get questions  
returned in search results (ie: what you're doing now)
* index both questions and answers, and search across both, and get a  
mixture of questions and answers returned.

In the latter situation, you could ensure that only one result per  
question is returned by doing the following in Question:
   has :id, :as => :question_id
And in Answer
   has question_id

And then for searching:
   ThinkingSphinx.search 'query',
     :group_by => 'question_id',
     :group_function => :attr

This way, you'll get a mixture of Questions and Answers, but no  
duplications of pairs.

Hope this helps.

-- 
Pat

On 21/08/2009, at 10:49 AM, Alejandro Riera wrote:

>
> So, no insights in this topic?
> Any idea will be welcomed :)
>
> Thx,
>
> Alex
>
> On Aug 15, 9:11 pm, Alejandro  Riera <[email protected]> wrote:
>> Hello everybody.
>>
>> I'm very happy with the results of sphinx and TS (thx Pat for it!)  
>> but
>> I have a problem I dont manage to resolve.
>>
>> My case is de following: I have 2 models: questions (Q) and asnwers
>> (A).
>> As you would expect Q has_many A and A belongs_to Q.
>>
>> What I want is to search inside both Q and A. So what I do right now
>> is the following:
>>
>>  class Question < ActiveRecord::Base
>>   has_many :answers
>>   define_index do
>>     indexes body
>>     indexes answers.body, :as => :answers
>>   end
>>  end
>>
>> The problem is that if sphinx (or TS I'm not sure) finds a match
>> inside an answer he is going to give me the question containing it
>> (even if the question doesn't matches the query). This might be a
>> little strange from the user point of view: he might see some results
>> that apparently don't match his search query.
>>
>> What I like to do is to show him the Question and, next to it, the
>> answer(s) containing the match.
>>
>> I would love TS to give me  an array like this: [Q, A, Q, Q, Q, A,
>> A, ....] each answer belonging to the question on his left.
>>
>> Do you think it is possible to make something like that?
>>
>> I've tried to be clear presenting the problem, if that's not the case
>> don't hesitate to ask me anything
>>
>> Thank you a lot
>>
>> Alex
> >


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