Hi Greg

I think the best approach is what you're hinting at in your final screenshot - 
a complex piece of SQL code that grabs the ids you need. You could look at your 
space_ids attribute for an example, and you can use the join method in your 
define_index block to force joins on associations that you're not using in any 
fields or attributes - although given you've got space_ids, I guess all the 
tables are referenced already.

If you're using MySQL, then an IF(manuals.draft = 0 AND sections.hidden = 0, 
spaces.id, 0) statement might do the trick (wrapped up in the standard concat 
statements)… PostgreSQL doesn't have an IF method, but you can get the same 
thing happening with a CASE statement instead.

Is that enough help? If you get stuck, let me know.

Cheers

-- 
Pat

On 16/11/2011, at 10:45 PM, Greg DeVore wrote:

> We are in the process of upgrading from Rails 2.3 to 3.x. We have been
> using TS for awhile but had to hack it a bit to make it do delta
> indexing on some complex joins we were doing. As we upgrade to Rails 3
> we want to make this "out of the box" with the current version of TS
> without having to hack up our own version. I am just not sure about
> the best way to setup the "has" index for the MVA value we want to
> index.
> 
> Here are some screenshots that show what we are trying to do:
> 
> http://gdevore.clarify-it.com/d/qz6ale
> 
> Basically I have a Lesson model that I need to add
> a :published_space_ids MVA to. The scope to get the
> published_spaces_ids for a lesson looks like this:
> 
> Space.joins(:manuals => {:sections
> => :readings}).where('readings.lesson_id = ?',
> self.id).where('manuals.draft = ? AND sections.hidden = ?', false,
> false)
> 
> I am not sure how to add this to the sphinx index for the Lesson
> model.
> 
> Thanks,
> 
> Greg
> 
> -- 
> 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