Hi Everyone, I have a question about indexing and searching relationships 
and I'd appreciate any help.


I have a User model that indexes ProfileAnswer, a has_many relationship. I 
am indexing profile_answers.response as well profile_answers.question_id .

I need to be able to run search queries that search a string for one 
particular question.

Here is the way I am doing this which is wrong. with data points

A{

profile_answer{
  id = 99
  question_id = 1
  answer = 'Hi'}

profile_answer{
  id = 100
  question_id = 2
  answer = 'Bye'}
}
B{

 profile_answer{
     id = 102
     question_id = 1
    answer = 'Bye'
 }

 profile_answer{
    id = 101
    question_id = 2
    answer = 'Hi'
 }
}

A and B are both returned when I search for 'Hi' on question_id = 2.

Here is my index definition:

 indexes profile_answers.answer, sortable: true, as: "answer"
 has profile_answers.question_id, as: "question_id"

and do my search as:

  User.search('@answer "Hi"', match_mode: :extended, with: {question_id: 
given_question.id})

I have tried indexing some combination of these columns and search that but 
that has never produced the right index.

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