Hi, I found my problem. It was nothing to do with the has_many
association! The syntax below is correct.

It was to do with the way I was processing the indexes. I was running
the rake task from cron as prescribed. The problem was that my app was
working in development mode and the rake tasks were running in
production. My setups are different for each environment so the
production rake task was adding the deltas to the production index.
Once the deltas had been marked done in the DB they disappeared from
the development index! Hence the inconsistent results.

Hope that helps someone else!

Cheers,

--
Barry

On Nov 22, 5:46 pm, Barry Paul <[email protected]> wrote:
> Hi, I'm having a problem getting results over a has_many association.
> My models are:
>
> class Question
>   has_many :answers
>
>   # this is the function I am having problems with
>   def get_equivalents(query)
>     answers.search query, :with => { :is_primary =>
> true }, :match_mode => :any, :per_page => 5
>   end
>
> end
>
> class Answer
>   belongs_to :question
>
>   # thinking sphinx indexes
>   define_index do
>     # fields
>     indexes content, :morphology => :stem_en
>
>     # attributes
>     has rank, popularity, question_id
>     has "ISNULL(equivalent_id)", :as => :is_primary, :type => :integer
>
>     set_property :delta => true
>   end
> end
>
> So the problem is if call get_equivalents on a question object I get
> zero results but if I do Answers.search I can see all the answers I'm
> looking for. So they have been indexed and my delta indexing seems to
> be working...
>
> Any ideas?
>
> Thanks,
>
> --
> Barry

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